-
Feature Request
-
Resolution: Done
-
Minor
-
1.3.22.Final
-
None
-
None
Following the pattern in the Undertow builder, to stop my server I'm first closing the AcceptingChannel then shutting down the Xnio worker.
Closing the AcceptingChannel seems to stop new connections, but it is the Xnio worker shutdown that actually closes existing connections. I am utilizing the Xnio worker thread pool to run cleanup tasks for websockets (via a close setter on the web socket channel).
The Xnio worker shutdown closes all connections, then shuts down the task pool, leading to the inability to execute on close tasks in the task pool during shutdown.
It would be nice to be able to stop the acceptor and close all active connections independently of shutting down the task pool.
Here's an example stack trace I get:
10:08:01,142 [XNIO-1 I/O-2] ERROR org.xnio.listener - XNIO001007: A channel event listener threw an exception java.util.concurrent.RejectedExecutionException: Task mycode.SerializingExecutor$$Lambda$433/1923483913@70c0d4c2 rejected from org.xnio.XnioWorker$TaskPool@349080c9[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 200728] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369) at org.xnio.XnioWorker.execute(XnioWorker.java:749) at mycode.SerializingExecutor.execute(SerializingExecutor.java:30) at mycode.WebSocketConnection.onClose(WebSocketConnection.java:85) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameCloseListener.handleEvent(AbstractFramedChannel.java:1021) at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameCloseListener.handleEvent(AbstractFramedChannel.java:937) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at org.xnio.conduits.WriteReadyHandler$ChannelListenerHandler.terminated(WriteReadyHandler.java:70) at org.xnio.nio.NioSocketConduit.writeTerminated(NioSocketConduit.java:201) at org.xnio.nio.NioSocketConduit.terminateWrites(NioSocketConduit.java:190) at org.xnio.nio.NioSocketConduit.truncateWrites(NioSocketConduit.java:195) at io.undertow.conduits.IdleTimeoutConduit.truncateWrites(IdleTimeoutConduit.java:377) at org.xnio.conduits.ConduitStreamSinkChannel.close(ConduitStreamSinkChannel.java:186) at org.xnio.IoUtils.safeClose(IoUtils.java:134) at org.xnio.conduits.WriteReadyHandler$ChannelListenerHandler.forceTermination(WriteReadyHandler.java:57) at org.xnio.nio.NioSocketConduit.forceTermination(NioSocketConduit.java:107) at org.xnio.nio.WorkerThread.run(WorkerThread.java:492)