mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-10-05 19:18:26 +00:00
take the bwt shutdown handle once across overlapping shutdowns, and do nothing in a shutdown that finds it taken
This commit is contained in:
@@ -227,15 +227,21 @@ public class Bwt {
|
||||
*
|
||||
*/
|
||||
private void shutdown() {
|
||||
if(shutdownPtr == null) {
|
||||
terminating = true;
|
||||
//The handle is taken before it is used, so that it is passed to the daemon once however many shutdowns are under way
|
||||
Long ptr;
|
||||
synchronized(this) {
|
||||
ptr = shutdownPtr;
|
||||
shutdownPtr = null;
|
||||
}
|
||||
|
||||
//A shutdown is only requested of a running daemon, so one finding no handle has been overtaken by another and has nothing to do
|
||||
if(ptr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBwtDaemon.shutdown(shutdownPtr);
|
||||
NativeBwtDaemon.shutdown(ptr);
|
||||
this.terminating = false;
|
||||
this.ready = false;
|
||||
this.shutdownPtr = null;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
@@ -342,7 +348,9 @@ public class Bwt {
|
||||
public void onBooting(long shutdownPtr) {
|
||||
log.debug("Booting bwt");
|
||||
|
||||
Bwt.this.shutdownPtr = shutdownPtr;
|
||||
synchronized(Bwt.this) {
|
||||
Bwt.this.shutdownPtr = shutdownPtr;
|
||||
}
|
||||
if(terminating) {
|
||||
Bwt.this.shutdown();
|
||||
terminating = false;
|
||||
|
||||
Reference in New Issue
Block a user