Fix memory leak with domains

This commit is contained in:
Brian M. Carlson 2014-04-12 00:29:20 -05:00
parent 492f1eb709
commit 9c87253aff
3 changed files with 6 additions and 14 deletions

View File

@ -19,6 +19,9 @@ var NativeQuery = function(config, values, callback) {
this.text = c.text;
this.values = c.values;
this.callback = c.callback;
if(process.domain && c.callback) {
this.callback = process.domain.bind(c.callback);
}
this.singleRowMode = false;
if(!this.callback) {

View File

@ -64,23 +64,9 @@ var pools = {
pool.acquire(function(err, client) {
if(domain) {
cb = domain.bind(cb);
domain.add(client);
//native clients do not have a connection object
if(client.connection) {
domain.add(client.connection);
domain.add(client.connection.stream);
}
}
if(err) return cb(err, null, function() {/*NOOP*/});
cb(null, client, function(err) {
if(domain) {
//native clients do not have a connection object
if(client.connection) {
domain.remove(client.connection.stream);
domain.remove(client.connection);
}
domain.remove(client);
}
if(err) {
pool.destroy(client);
} else {

View File

@ -20,6 +20,9 @@ var Query = function(config, values, callback) {
//use unique portal name each time
this.portal = config.portal || "";
this.callback = config.callback;
if(process.domain && config.callback) {
this.callback = process.domain.bind(config.callback);
}
this._fieldNames = [];
this._fieldConverters = [];
this._result = new Result(config.rowMode);