File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
src/main/java/org/java_websocket/server Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -253,8 +253,7 @@ public void stop( int timeout ) throws InterruptedException {
253253 wsf .close ();
254254
255255 synchronized ( this ) {
256- if ( selectorthread != null && selectorthread != Thread .currentThread () ) {
257- selectorthread .interrupt ();
256+ if ( selectorthread != null ) {
258257 selector .wakeup ();
259258 selectorthread .join ( timeout );
260259 }
@@ -329,11 +328,19 @@ public void run() {
329328 return ;
330329 }
331330 try {
332- while ( !selectorthread .isInterrupted () ) {
331+ int iShutdownCount = 5 ;
332+ int selectTimeout = 0 ;
333+ while ( !selectorthread .isInterrupted () && iShutdownCount != 0 ) {
333334 SelectionKey key = null ;
334335 WebSocketImpl conn = null ;
335336 try {
336- selector .select ();
337+ if (isclosed .get ()) {
338+ selectTimeout = 5 ;
339+ }
340+ int keyCount = selector .select ( selectTimeout );
341+ if (keyCount == 0 && isclosed .get ()) {
342+ iShutdownCount --;
343+ }
337344 Set <SelectionKey > keys = selector .selectedKeys ();
338345 Iterator <SelectionKey > i = keys .iterator ();
339346
You can’t perform that action at this time.
0 commit comments