Skip to content

Commit

Permalink
attempts to fix issue tediousjs#19
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-page committed Apr 10, 2015
1 parent 89ad875 commit 6b9eb80
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ The following method is added to the Tedious [Connection](http://pekim.github.co
### Connection.release()
Release the connect back to the pool to be used again

## Version 0.3.6 Changes
* bug fix only

## Version 0.3.5 Changes
* `poolConfig` option `min` is limited to less than `max`

Expand Down
14 changes: 10 additions & 4 deletions lib/connection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function createConnection(pooled) {

pooled.status = RETRY;
pooled.con = undefined;
if (pooled.timeout) {
clearTimeout(pooled.timeout);
pooled.timeout = undefined;
}
connection.removeAllListeners('end');
connection.close();

Expand Down Expand Up @@ -199,10 +203,14 @@ ConnectionPool.prototype.acquire = function (callback) {

function setUsed(pooled, waiter) {
pooled.status = USED;
if (pooled.timeout)
if (pooled.timeout) {
clearTimeout(pooled.timeout);
if (waiter.timeout)
pooled.timeout = undefined;
}
if (waiter.timeout) {
clearTimeout(waiter.timeout);
waiter.timeout = undefined;
}
waiter.callback(null, pooled.con);
}

Expand All @@ -216,8 +224,6 @@ function setFree(pooled) {
}, this.idleTimeout);
}



ConnectionPool.prototype.release = function(connection) {
if (this.drained) //pool has been drained
return;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tedious-connection-pool",
"version": "0.3.5",
"version": "0.3.6",
"description": "Connection Pool for tedious.",
"main": "lib/connection-pool.js",
"scripts": {
Expand Down

0 comments on commit 6b9eb80

Please sign in to comment.