This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


The following commit(s) were added to refs/heads/master by this push:
     new 4fd8d46  [SSHD-911] Check if client session/channel is open before 
writing a message through ClientChannelPendingMessagesQueue
4fd8d46 is described below

commit 4fd8d465b3053573ce60ac7a6af122010740205f
Author: Lyor Goldstein <[email protected]>
AuthorDate: Mon Apr 22 13:13:55 2019 +0300

    [SSHD-911] Check if client session/channel is open before writing a message 
through ClientChannelPendingMessagesQueue
---
 .../client/channel/ClientChannelPendingMessagesQueue.java     | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelPendingMessagesQueue.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelPendingMessagesQueue.java
index e6ab058..eedba37 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelPendingMessagesQueue.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelPendingMessagesQueue.java
@@ -35,6 +35,7 @@ import java.util.function.Consumer;
 import org.apache.sshd.client.future.DefaultOpenFuture;
 import org.apache.sshd.client.future.OpenFuture;
 import org.apache.sshd.common.future.SshFutureListener;
+import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
 
@@ -148,6 +149,7 @@ public class ClientChannelPendingMessagesQueue
 
             if (enqueue) {
                 pendingQueue.add(new SimpleImmutableEntry<>(buffer, 
errHandler));
+                pendingQueue.notifyAll();   // in case anyone is waiting
             } else {
                 writeMessage(buffer, errHandler);
             }
@@ -163,6 +165,15 @@ public class ClientChannelPendingMessagesQueue
                 throw new EOFException("Queue is marked as closed");
             }
 
+            if (!channel.isOpen()) {
+                throw new EOFException("Client channel is closed/closing");
+            }
+
+            Session session = channel.getSession();
+            if (!session.isOpen()) {
+                throw new EOFException("Client session is closed/closing");
+            }
+
             OutputStream outputStream = channel.getInvertedIn();
             outputStream.write(buffer.array(), buffer.rpos(), 
buffer.available());
             outputStream.flush();

Reply via email to