handle connection disconnect and shut down off UserThread
This commit is contained in:
parent
43f177d1f9
commit
e1ca35172d
@ -32,7 +32,6 @@ import haveno.network.p2p.storage.payload.CapabilityRequiringPayload;
|
|||||||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||||
|
|
||||||
import haveno.common.Proto;
|
import haveno.common.Proto;
|
||||||
import haveno.common.UserThread;
|
|
||||||
import haveno.common.app.Capabilities;
|
import haveno.common.app.Capabilities;
|
||||||
import haveno.common.app.HasCapabilities;
|
import haveno.common.app.HasCapabilities;
|
||||||
import haveno.common.app.Version;
|
import haveno.common.app.Version;
|
||||||
@ -502,7 +501,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||||||
handleException(t);
|
handleException(t);
|
||||||
} finally {
|
} finally {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
UserThread.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler));
|
EXECUTOR.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler));
|
||||||
}
|
}
|
||||||
}, "Connection:SendCloseConnectionMessage-" + this.uid).start();
|
}, "Connection:SendCloseConnectionMessage-" + this.uid).start();
|
||||||
} else {
|
} else {
|
||||||
@ -512,12 +511,12 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||||||
} else {
|
} else {
|
||||||
//TODO find out why we get called that
|
//TODO find out why we get called that
|
||||||
log.debug("stopped was already at shutDown call");
|
log.debug("stopped was already at shutDown call");
|
||||||
UserThread.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler));
|
EXECUTOR.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doShutDown(CloseConnectionReason closeConnectionReason, @Nullable Runnable shutDownCompleteHandler) {
|
private void doShutDown(CloseConnectionReason closeConnectionReason, @Nullable Runnable shutDownCompleteHandler) {
|
||||||
UserThread.execute(() -> connectionListener.onDisconnect(closeConnectionReason, this));
|
EXECUTOR.execute(() -> connectionListener.onDisconnect(closeConnectionReason, this));
|
||||||
try {
|
try {
|
||||||
protoOutputStream.onConnectionShutdown();
|
protoOutputStream.onConnectionShutdown();
|
||||||
socket.close();
|
socket.close();
|
||||||
@ -540,7 +539,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||||||
|
|
||||||
log.debug("Connection shutdown complete {}", this);
|
log.debug("Connection shutdown complete {}", this);
|
||||||
if (shutDownCompleteHandler != null)
|
if (shutDownCompleteHandler != null)
|
||||||
UserThread.execute(shutDownCompleteHandler);
|
EXECUTOR.execute(shutDownCompleteHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user