This is an automated email from the ASF dual-hosted git repository.
gnodet 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 7d77e6d97 Use a singleton threadpool for kex message handler flushing
(#459) (fixes #458)
7d77e6d97 is described below
commit 7d77e6d9795405c03b2ad4cc5a2977c5e9329660
Author: FliegenKLATSCH <[email protected]>
AuthorDate: Tue Jan 30 09:31:15 2024 +0100
Use a singleton threadpool for kex message handler flushing (#459) (fixes
#458)
---
.../session/helpers/KeyExchangeMessageHandler.java | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
index 4ad8db4e1..a5853e06e 100644
---
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
+++
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
@@ -28,7 +28,6 @@ import java.util.Objects;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -75,18 +74,18 @@ public class KeyExchangeMessageHandler {
// re-acquires the write lock, so normally not many readers (i.e.,
writePacket() calls) will get a chance to enqueue
// new packets.
- /**
- * We need the flushing thread to have priority over writing threads. So
we use a lock that favors writers over
- * readers, and any state updates and the flushing thread are writers,
while writePacket() is a reader.
- */
- protected final ReentrantReadWriteLock lock = new
ReentrantReadWriteLock(false);
-
/**
* An {@link ExecutorService} used to flush the queue asynchronously.
*
* @see #flushQueue(DefaultKeyExchangeFuture)
*/
- protected final ExecutorService flushRunner =
Executors.newSingleThreadExecutor();
+ protected static ExecutorService flushRunner =
ThreadUtils.newCachedThreadPool("kex-flusher");
+
+ /**
+ * We need the flushing thread to have priority over writing threads. So
we use a lock that favors writers over
+ * readers, and any state updates and the flushing thread are writers,
while writePacket() is a reader.
+ */
+ protected final ReentrantReadWriteLock lock = new
ReentrantReadWriteLock(false);
/**
* The {@link AbstractSession} this {@link KeyExchangeMessageHandler}
belongs to.
@@ -209,7 +208,6 @@ public class KeyExchangeMessageHandler {
kexFlushedFuture.get());
});
items.getValue().setValue(Boolean.valueOf(items.getKey().intValue() ==
0));
- flushRunner.shutdownNow();
}
/**