Tweak connector switching to prevent a race condition
This commit is contained in:
parent
0aa0966a28
commit
75f4360175
2 changed files with 8 additions and 6 deletions
|
@ -53,6 +53,11 @@ Zotero.IPC = new function() {
|
|||
switchConnectorMode(true);
|
||||
} else if(msg === "lockReleased") {
|
||||
Zotero.onDBLockReleased();
|
||||
} else if(msg === "checkInitComplete") {
|
||||
while(!Zotero.initialized) {
|
||||
Zotero.mainThread.processNextEvent(true)
|
||||
}
|
||||
Zotero.IPC.broadcast("initComplete");
|
||||
} else if(msg === "initComplete") {
|
||||
Zotero.onInitComplete();
|
||||
}
|
||||
|
|
|
@ -438,10 +438,13 @@ if(appInfo.platformVersion[0] >= 2) {
|
|||
// Wait for initComplete message if we switched to connector because standalone was
|
||||
// started. This shouldn't loop indefinitely, but even if it does, it won't hang
|
||||
// anything (since it will stop looping on shutdown).
|
||||
Zotero.IPC.broadcast("checkInitComplete");
|
||||
Zotero.debug("Waiting for initComplete message");
|
||||
_waitingForInitComplete = true;
|
||||
while(_waitingForInitComplete && !Zotero.closing) {
|
||||
Zotero.mainThread.processNextEvent(true);
|
||||
}
|
||||
Zotero.debug("initComplete message received");
|
||||
if(Zotero.closing) return false;
|
||||
}
|
||||
|
||||
|
@ -461,9 +464,6 @@ if(appInfo.platformVersion[0] >= 2) {
|
|||
observerService.notifyObservers(Zotero, "zotero-reloaded", null);
|
||||
}
|
||||
|
||||
// Broadcast initComplete message if desired
|
||||
if(_broadcastInitComplete) Zotero.IPC.broadcast("initComplete");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -696,9 +696,6 @@ if(appInfo.platformVersion[0] >= 2) {
|
|||
}
|
||||
if(Zotero.closing) return false;
|
||||
|
||||
// We will want to broadcast when initialization completes
|
||||
_broadcastInitComplete = true;
|
||||
|
||||
// Run a second init with haveReleasedLock = true, so that
|
||||
// if we still can't acquire a DB lock, we will give up
|
||||
return _initDB(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue