Skip to content

Commit

Permalink
[debug] Better debug messages to try to determine if pool is slowly l…
Browse files Browse the repository at this point in the history
…osing clients to forever busy
  • Loading branch information
indexzero committed Sep 17, 2010
1 parent 7c2eb5d commit dd1918d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var sys = require('sys'),
pool = require('./../vendor/pool/main'),
eyes = require('eyes'),
min = 0,
max = 100;
max = 10;

// Setup the PoolManager
var manager = pool.createPoolManager();
Expand Down Expand Up @@ -146,7 +146,7 @@ HttpProxy.prototype = {

// Open new HTTP request to internal resource with will act as a reverse proxy pass
var p = manager.getPool(port, server);
sys.puts('current pool count for ' + req.headers.host + ":" + port + ' ' +p.clients.length);
sys.puts('Current pool count for ' + req.headers.host + ":" + port + ' ' + p.clients.length + ', Busy: ' + p.getBusy() + ', Free: ' + p.getFree());

p.on('error', function (err) {
// Remark: We should probably do something here
Expand Down
9 changes: 9 additions & 0 deletions vendor/pool/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ Pool.prototype.onFree = function (client) {
if (this.pending.length > 0) this.pending.shift()(client);
};

Pool.prototype.getFree = function () {
return this.clients.filter(function (client) { return !client.busy }).length;
};

Pool.prototype.getBusy = function () {
return this.clients.filter(function (client) { return client.busy }).length;
};

Pool.prototype.setMinClients = function (num) {
this.minClients = num;
if (this.clients.length < num) {
Expand All @@ -98,6 +106,7 @@ Pool.prototype.setMinClients = function (num) {
Pool.prototype.setMaxClients = function (num) {
this.maxClients = num;
};

Pool.prototype.end = function () {
this.clients.forEach(function (c) {c.end()});
};
Expand Down

0 comments on commit dd1918d

Please sign in to comment.