File tree Expand file tree Collapse file tree
src/main/java/org/xbill/DNS Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ public static void close() {
9494 }
9595
9696 private static void close (boolean fromHook ) {
97+ log .debug ("Closing dnsjava NIO selector, fromHook={}" , fromHook );
9798 run = false ;
9899 Selector localSelector = selector ;
99100 if (localSelector != null ) {
@@ -139,7 +140,14 @@ static void runSelector() {
139140
140141 while (run ) {
141142 try {
142- if (selector .select (timeout ) == 0 ) {
143+ int numSelects = selector .select (timeout );
144+ if (Thread .currentThread ().isInterrupted ()) {
145+ log .debug ("Sector thread was interrupted, stopping" );
146+ close ();
147+ break ;
148+ }
149+
150+ if (numSelects == 0 ) {
143151 runTasks (TIMEOUT_TASKS );
144152 }
145153
Original file line number Diff line number Diff line change @@ -66,11 +66,10 @@ private void checkTransactionTimeouts() {
6666 private void closeTcp () {
6767 registrationQueue .clear ();
6868 EOFException closing = new EOFException ("Client is closing" );
69- channelMap .forEach (
70- (key , state ) -> {
71- state .handleTransactionException (closing );
72- state .handleChannelException (closing );
73- });
69+ for (ChannelState state : channelMap .values ()) {
70+ state .handleTransactionException (closing );
71+ state .handleChannelException (closing );
72+ }
7473 channelMap .clear ();
7574 }
7675
You can’t perform that action at this time.
0 commit comments