Skip to content

Commit 3fd0403

Browse files
Merge pull request TooTallNate#329 from bendem/fix/stop-hanging
FixTooTallNate#259 stop joining thread before interrupting Selector.select
2 parents ac45d84 + e4c248a commit 3fd0403

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

‎src/main/java/org/java_websocket/server/WebSocketServer.java‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,10 @@ public void stop( int timeout ) throws InterruptedException{
216216
}
217217

218218
synchronized ( this ){
219-
if( selectorthread != null ){
220-
if( Thread.currentThread() != selectorthread ){
221-
222-
}
223-
if( selectorthread != Thread.currentThread() ){
224-
if( socketsToClose.size() > 0 )
225-
selectorthread.join( timeout );// isclosed will tell the selectorthread to go down after the last connection was closed
226-
selectorthread.interrupt();// in case the selectorthread did not terminate in time we send the interrupt
227-
selectorthread.join();
228-
}
219+
if( selectorthread != null && selectorthread != Thread.currentThread() ){
220+
selector.wakeup();
221+
selectorthread.interrupt();
222+
selectorthread.join( timeout );
229223
}
230224
}
231225
}

0 commit comments

Comments
(0)