From c7400cad8000d7fd659ec3259e6bed1c2cdc9c0a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 28 Sep 2013 01:06:10 -0400 Subject: [PATCH] tcp-client: do not leak sockets If one object has connect() called more than once (like when reconnecting), make sure we destroy the previous socket rather than leaking it. --- js/tcp-client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/tcp-client.js b/js/tcp-client.js index ec61399..dd0c189 100644 --- a/js/tcp-client.js +++ b/js/tcp-client.js @@ -110,6 +110,9 @@ Author: Boris Smus (smus@chromium.org) * @param {Object} createInfo The socket details */ TcpClient.prototype._onCreate = function(createInfo) { + if (this.socketId !== null) { + socket.destroy(this.socketId); + } this.socketId = createInfo.socketId; if (this.socketId > 0) { socket.connect(this.socketId, this.host, this.port, this._onConnectComplete.bind(this)); -- 2.39.2