Skip to content

Commit

Permalink
updated close function for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
unilaterus committed Aug 14, 2014
1 parent a3d0219 commit 8be9d94
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/http-proxy/index.js
Expand Up @@ -134,8 +134,16 @@ ProxyServer.prototype.listen = function(port, hostname) {

ProxyServer.prototype.close = function(callback) {
if (this._server) {
this._server.close(callback);
this._server = null;
// Wrap callback to nullify server after all open connections are closed.
var callback_wrapper = function() {
this._server = null;

if (callback) {
callback(arguments);
}
};

this._server.close(callback_wrapper);
}
};

Expand Down

0 comments on commit 8be9d94

Please sign in to comment.