Issue #2788 - Graceful close of HTTP/2 Connection.

Updates after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-02-07 17:56:34 +01:00
parent 92d9d46f8e
commit 8b1a669e65
2 changed files with 5 additions and 1 deletions

View File

@ -720,6 +720,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
if (LOG.isDebugEnabled())
LOG.debug("Ignoring shutdown, already closed");
Callback.Completable result = closeCallback;
// Result may be null if the shutdown is in progress,
// don't wait and return a completed CompletableFuture.
return result != null ? result : CompletableFuture.completedFuture(null);
}
}
@ -1077,7 +1079,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
{
Callback.Completable callback = closeCallback;
// Only send the close frame if we can flip Hi, see shutdown().
if (callback != null && streamCount.compareAndSetHi(0, 1))
if (callback != null && streamCount.compareAndSet(0, 1, 0, 0))
control(null, callback, closeFrame);
}
}

View File

@ -156,6 +156,8 @@ public interface ISession extends Session
/**
* <p>Gracefully closes the session, returning a {@code CompletableFuture} that
* is completed when all the streams currently being processed are completed.</p>
* <p>Implementation is idempotent, i.e. calling this method a second time
* or concurrently results in a no-operation.</p>
*
* @return a {@code CompletableFuture} that is completed when all the streams are completed
*/