Solve some database reconnection issues

This commit is contained in:
calzoneman 2013-08-15 09:47:52 -05:00
parent 98b6273dc4
commit 8776ae15fc

View file

@ -41,12 +41,22 @@ function getConnection() {
Logger.errlog.log("DB connection failed"); Logger.errlog.log("DB connection failed");
return false; return false;
} }
if(CONFIG["debug"]) { db._querySync = db.querySync;
db._querySync = db.querySync; db.querySync = function(q) {
db.querySync = function(q) { if(!this.connectedSync()) {
Logger.syslog.log("DEBUG: " + q); db = false;
return this._querySync(q); return false;
} }
var res = this._querySync(q);
if(!res) {
try {
db.closeSync();
} catch(e) {
// already disconnected
}
db = false;
}
return res;
} }
return db; return db;
} }