tomaswolf commented on code in PR #218:
URL: https://github.com/apache/mina-sshd/pull/218#discussion_r854828577
##########
sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java:
##########
@@ -127,6 +129,28 @@ protected CloseFuture doCloseGracefully() {
return builder().when(pendingWrite.get()).build().close(false);
}
+ @Override
+ protected void doCloseImmediately() {
+ Channel channel = getChannel();
+ long channelId = (channel == null) ? -1L : channel.getChannelId();
+ abortCurrentWrite(() -> new SshChannelClosedException(channelId,
"Channel closed before pending write completed"));
+
+ super.doCloseImmediately();
+ }
+
+ protected synchronized IoWriteFutureImpl abortCurrentWrite(Supplier<?
extends Exception> errorProvider) {
+ IoWriteFutureImpl future = pendingWrite.get();
+ if ((future != null) && (!future.isDone())) {
+ Exception error = errorProvider.get();
+ log.debug("abortCurrentWrite({}) aborting pending write={} - {} :
{}",
+ this, future, error == null ? null :
error.getClass().getSimpleName(),
+ error == null ? null : error.getMessage());
+ future.setValue(error);
+ }
+
+ return future;
+ }
Review Comment:
Terminating the current future is probably right, but still I don't think
this will help in all situations. On a graceful shutdown,
`AbstractCloseable.close` will call `doCloseGracefully()` *first*, which will
block until the pending future is fulfilled.
However, it also calls `preClose()` first, which will already close the
`packetWriter`.
I'm not sure a `ChannelAsyncOutputStream` *can* be closed gracefully in this
situation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]