do not set daemon connection to null on disconnect

This commit is contained in:
woodser 2024-01-03 07:40:22 -05:00
parent ba8a9ae21d
commit 497de47965

View File

@ -417,7 +417,8 @@ public final class XmrConnectionService {
if (isConnected) {
setConnection(connection.getUri());
} else if (getConnection() != null && getConnection().getUri().equals(connection.getUri())) {
setConnection(getBestAvailableConnection()); // switch to best connection
MoneroRpcConnection bestConnection = getBestAvailableConnection();
if (bestConnection != null) setConnection(bestConnection); // switch to best connection
}
}
});
@ -533,8 +534,12 @@ public final class XmrConnectionService {
}
private void onConnectionChanged(MoneroRpcConnection currentConnection) {
log.info("XmrConnectionService.onConnectionChanged() uri={}, connected={}", currentConnection == null ? null : currentConnection.getUri(), currentConnection == null ? "false" : currentConnection.isConnected());
if (isShutDownStarted) return;
log.info("XmrConnectionService.onConnectionChanged() uri={}, connected={}", currentConnection == null ? null : currentConnection.getUri(), currentConnection == null ? "false" : currentConnection.isConnected());
if (currentConnection == null) {
log.warn("Setting daemon connection to null");
Thread.dumpStack();
}
synchronized (lock) {
if (currentConnection == null) {
daemon = null;
@ -660,8 +665,12 @@ public final class XmrConnectionService {
}
new Thread(() -> {
if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection());
else connectionManager.checkConnection();
if (connectionManager.getAutoSwitch()) {
MoneroRpcConnection bestConnection = getBestAvailableConnection();
if (bestConnection != null) connectionManager.setConnection(bestConnection);
} else {
connectionManager.checkConnection();
}
// set error message
if (!Boolean.TRUE.equals(connectionManager.isConnected()) && HavenoUtils.havenoSetup != null) {