Bug 1041433 - UnifiedComplete: Close connections on Sqlite.shutdown.addBlocker. r=mano

This commit is contained in:
Marco Bonardo 2014-09-30 12:40:18 +02:00
parent 15ad19eabf
commit 9f73c6e8fa
2 changed files with 13 additions and 25 deletions

View File

@ -1921,6 +1921,7 @@ XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised", () => {
catch(ex) {
// It's too late to block shutdown, just close the connection.
return conn.close();
throw (ex);
}
return Promise.resolve();
}).then(null, Cu.reportError);

View File

@ -11,7 +11,6 @@
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
const TOPIC_SHUTDOWN = "places-shutdown";
const TOPIC_PREFCHANGED = "nsPref:changed";
const DEFAULT_BEHAVIOR = 0;
@ -1463,19 +1462,9 @@ Search.prototype = {
//// component @mozilla.org/autocomplete/search;1?name=unifiedcomplete
function UnifiedComplete() {
Services.obs.addObserver(this, TOPIC_SHUTDOWN, true);
}
UnifiedComplete.prototype = {
//////////////////////////////////////////////////////////////////////////////
//// nsIObserver
observe: function (subject, topic, data) {
if (topic === TOPIC_SHUTDOWN) {
this.ensureShutdown();
}
},
//////////////////////////////////////////////////////////////////////////////
//// Database handling
@ -1500,6 +1489,18 @@ UnifiedComplete.prototype = {
readOnly: true
});
try {
Sqlite.shutdown.addBlocker("Places UnifiedComplete.js clone closing",
Task.async(function* () {
SwitchToTabStorage.shutdown();
yield conn.close();
}));
} catch (ex) {
// It's too late to block shutdown, just close the connection.
yield conn.close();
throw ex;
}
// Autocomplete often fallbacks to a table scan due to lack of text
// indices. A larger cache helps reducing IO and improving performance.
// The value used here is larger than the default Storage value defined
@ -1515,20 +1516,6 @@ UnifiedComplete.prototype = {
return this._promiseDatabase;
},
/**
* Used to stop running queries and close the database handle.
*/
ensureShutdown: function () {
if (this._promiseDatabase) {
Task.spawn(function* () {
let conn = yield this.getDatabaseHandle();
SwitchToTabStorage.shutdown();
yield conn.close()
}.bind(this)).then(null, Cu.reportError);
this._promiseDatabase = null;
}
},
//////////////////////////////////////////////////////////////////////////////
//// mozIPlacesAutoComplete