Solve some database reconnection issues

This commit is contained in:
calzoneman 2013-08-15 09:47:52 -05:00
parent 98b6273dc4
commit 8776ae15fc
1 changed files with 15 additions and 5 deletions

View File

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