0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00

net: don't throw on immediately destroyed socket

Fixes regression introduced in af249fa8a1.

With connect being deferred to the next tick, Socket.destroy could be
called before connect. Socket.destroy sets _connecting to false which
would cause an assertion error.

Fixes: https://github.com/nodejs/io.js/issues/2250
PR-URL: https://github.com/nodejs/io.js/pull/2251
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
Evan Lucas 2015-07-26 19:24:28 -05:00
parent 2ca5a3db47
commit 503b089dd8
2 changed files with 10 additions and 1 deletions

View File

@ -927,7 +927,8 @@ function lookupAndConnect(self, options) {
var addressType = exports.isIP(host);
if (addressType) {
process.nextTick(function() {
connect(self, host, port, addressType, localAddress, localPort);
if (self._connecting)
connect(self, host, port, addressType, localAddress, localPort);
});
return;
}

View File

@ -0,0 +1,8 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
const socket = net.connect(common.PORT, common.localhostIPv4, assert.fail);
socket.on('error', assert.fail);
socket.destroy();