projects
/
ldk-java
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ebef1f8
)
[Java] Close all sockets cleanly on `NioPeerHandler::interrupt`
author
Matt Corallo
<git@bluematt.me>
Tue, 1 Feb 2022 22:33:02 +0000
(22:33 +0000)
committer
Matt Corallo
<git@bluematt.me>
Wed, 2 Feb 2022 19:30:47 +0000
(19:30 +0000)
src/main/java/org/ldk/batteries/NioPeerHandler.java
patch
|
blob
|
history
diff --git
a/src/main/java/org/ldk/batteries/NioPeerHandler.java
b/src/main/java/org/ldk/batteries/NioPeerHandler.java
index 2ab48d627a67c0405d985cd6fdaf78969b276ff1..5963506feddf76b518c41b8a18f31a51fe4b8037 100644
(file)
--- a/
src/main/java/org/ldk/batteries/NioPeerHandler.java
+++ b/
src/main/java/org/ldk/batteries/NioPeerHandler.java
@@
-332,10
+332,12
@@
public class NioPeerHandler {
}
/**
}
/**
- * Interrupt the background thread, stopping all peer handling. Disconnection events to the PeerHandler are not made,
- * potentially leaving the PeerHandler in an inconsistent state.
+ * Interrupt the background thread, stopping all peer handling.
+ *
+ * After this method is called, the behavior of future calls to methods on this NioPeerHandler are undefined.
*/
public void interrupt() {
*/
public void interrupt() {
+ this.peer_manager.disconnect_all_peers();
shutdown = true;
selector.wakeup();
try {
shutdown = true;
selector.wakeup();
try {
@@
-347,6
+349,7
@@
public class NioPeerHandler {
for (ServerSocketChannel chan : listening_sockets) {
chan.close();
}
for (ServerSocketChannel chan : listening_sockets) {
chan.close();
}
+ listening_sockets.clear();
} catch (IOException ignored) {}
}
Reference.reachabilityFence(this.peer_manager); // Almost certainly overkill, but no harm in it
} catch (IOException ignored) {}
}
Reference.reachabilityFence(this.peer_manager); // Almost certainly overkill, but no harm in it