Permalink
Browse files

Fix socket leaks when FIN packet isn't responded to

  • Loading branch information...
piscisaureus authored and mmalecki committed Jul 24, 2012
1 parent 0d00b06 commit 24b84068eac1c704d9f8df3dc833b976850c328f
Showing with 2 additions and 6 deletions.
  1. +2 −6 lib/node-http-proxy/http-proxy.js
@@ -500,8 +500,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
}
catch (ex) {
detach();
- reverseProxy.incoming.socket.end();
- proxySocket.end();
}
}
});
@@ -532,8 +530,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
}
catch (ex) {
detach();
- proxySocket.end();
- socket.end();
}
});
@@ -542,8 +538,10 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// from `reverseProxy` and `proxySocket`.
//
function detach() {
+ proxySocket.destroySoon();
proxySocket.removeListener('end', listeners.onIncomingClose);
proxySocket.removeListener('data', listeners.onIncoming);
+ reverseProxy.incoming.socket.destroySoon();
reverseProxy.incoming.socket.removeListener('end', listeners.onOutgoingClose);
reverseProxy.incoming.socket.removeListener('data', listeners.onOutgoing);
}
@@ -553,7 +551,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// detach all event listeners.
//
proxySocket.on('end', listeners.onIncomingClose = function() {
- reverseProxy.incoming.socket.end();
detach();
// Emit the `end` event now that we have completed proxying
@@ -565,7 +562,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// event listeners.
//
reverseProxy.incoming.socket.on('end', listeners.onOutgoingClose = function() {
- proxySocket.end();
detach();
});
}

0 comments on commit 24b8406

Please sign in to comment.