http: tiny fix in http.js
authorYoshihiro Kikuchi <yknetg@gmail.com>
Thu, 13 Oct 2011 08:48:30 +0000 (17:48 +0900)
committerkoichik <koichik@improvement.jp>
Sun, 16 Oct 2011 16:14:45 +0000 (01:14 +0900)
Fixes #1885.

lib/http.js

index b306855..dc83ec6 100644 (file)
@@ -956,8 +956,11 @@ Agent.prototype.createSocket = function(name, host, port) {
   return s;
 };
 Agent.prototype.removeSocket = function(s, name, host, port) {
-  if (this.sockets[name] && this.sockets[name].indexOf(s) !== -1) {
-    this.sockets[name].shift(this.sockets[name].indexOf(s));
+  if (this.sockets[name]) {
+    var index = this.sockets[name].indexOf(s);
+    if (index !== -1) {
+      this.sockets[name].splice(index, 1);
+    }
   } else if (this.sockets[name] && this.sockets[name].length === 0) {
     // don't leak
     delete this.sockets[name];