Fix memory leak with domains
This commit is contained in:
parent
492f1eb709
commit
9c87253aff
@ -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) {
|
||||
|
14
lib/pool.js
14
lib/pool.js
@ -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 {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user