This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2069
- Loading branch information
Showing
4 changed files
with
41 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -896,6 +896,10 @@ function Agent(options) { | |
var name = host + ':' + port; | ||
if (self.requests[name] && self.requests[name].length) { | ||
self.requests[name].shift().onSocket(socket); | ||
if (self.requests[name].length === 0) { | ||
// don't leak | ||
delete this.requests[name]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
koichik
Author
|
||
} | ||
} else { | ||
// If there are no pending requests just destroy the | ||
// socket and it will get removed from the pool. This | ||
|
@@ -963,11 +967,11 @@ Agent.prototype.removeSocket = function(s, name, host, port) { | |
var index = this.sockets[name].indexOf(s); | ||
if (index !== -1) { | ||
this.sockets[name].splice(index, 1); | ||
if (this.sockets[name].length === 0) { | ||
// don't leak | ||
delete this.sockets[name]; | ||
} | ||
} | ||
} else if (this.sockets[name] && this.sockets[name].length === 0) { | ||
// don't leak | ||
delete this.sockets[name]; | ||
delete this.requests[name]; | ||
} | ||
if (this.requests[name] && this.requests[name].length) { | ||
// If we have pending requests and a socket gets closed a new one | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
should use 'self.requests[name]' instead of 'this.requests[name]' ?