diff --git a/lib/connection-pool.js b/lib/connection-pool.js index ba169da..f6fe152 100755 --- a/lib/connection-pool.js +++ b/lib/connection-pool.js @@ -3,9 +3,9 @@ var Connection = require('tedious').Connection; var EventEmitter = require('events').EventEmitter; var util = require('util'); -Connection.prototype.release = function() { +function release() { this.pool.release(this); -}; +} var PENDING = 0; var FREE = 1; @@ -63,6 +63,7 @@ function createConnection(pooled) { this.log('creating connection: ' + cid); var connection = new Connection(this.connectionConfig); + connection.release = release; connection.pool = this; if (pooled) { pooled.id = cid++; @@ -113,7 +114,7 @@ function createConnection(pooled) { connection.on('error', handleError); - var endHandler = function () { + endHandler = function () { self.log('connection ended: ' + pooled.id); if (self.drained) //pool has been drained return;