Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/org/xbill/DNS/NioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static void close() {
}

private static void close(boolean fromHook) {
log.debug("Closing dnsjava NIO selector, fromHook={}", fromHook);
run = false;
Selector localSelector = selector;
if (localSelector != null) {
Expand Down Expand Up @@ -139,7 +140,14 @@ static void runSelector() {

while (run) {
try {
if (selector.select(timeout) == 0) {
int numSelects = selector.select(timeout);
if (Thread.currentThread().isInterrupted()) {
log.debug("Sector thread was interrupted, stopping");
close();
break;
}

if (numSelects == 0) {
runTasks(TIMEOUT_TASKS);
}

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/xbill/DNS/NioTcpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ private void checkTransactionTimeouts() {
private void closeTcp() {
registrationQueue.clear();
EOFException closing = new EOFException("Client is closing");
channelMap.forEach(
(key, state) -> {
state.handleTransactionException(closing);
state.handleChannelException(closing);
});
for (ChannelState state : channelMap.values()) {
state.handleTransactionException(closing);
state.handleChannelException(closing);
}
channelMap.clear();
}

Expand Down
Loading