Fix socket leaks when FIN packet isn't responded to

This commit is contained in:
Bert Belder 2012-07-24 22:13:38 +02:00 committed by Maciej Małecki
parent 0d00b06af3
commit 24b84068ea

View File

@ -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();
});
}