Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
indutny committed Feb 19, 2015
commit 416ca343d8473a600993f4b59c964aac75b32e26
23 changes: 11 additions & 12 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ function Socket(options) {
}
util.inherits(Socket, stream.Duplex);

Socket.prototype._unrefTimer = function unrefTimer() {
for (var s = this; s !== null; s = s._parent)
timers._unrefActive(s);
};

// the user has called .end(), and all the bytes have been
// sent out to the other side.
// If allowHalfOpen is false, or if the readable side has
Expand Down Expand Up @@ -492,8 +497,7 @@ function onread(nread, buffer) {
var self = handle.owner;
assert(handle === self._handle, 'handle != self._handle');

for (var s = self; s !== null; s = s._parent)
timers._unrefActive(s);
self._unrefTimer();

debug('onread', nread);

Expand Down Expand Up @@ -624,8 +628,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
this._pendingData = null;
this._pendingEncoding = '';

for (var s = this; s !== null; s = s._parent)
timers._unrefActive(s);
this._unrefTimer();

if (!this._handle) {
this._destroy(new Error('This socket is closed.'), cb);
Expand Down Expand Up @@ -753,8 +756,7 @@ function afterWrite(status, handle, req, err) {
return;
}

for (var s = self; s !== null; s = s._parent)
timers._unrefActive(s);
self._unrefTimer();

if (self !== process.stderr && self !== process.stdout)
debug('afterWrite call cb');
Expand Down Expand Up @@ -869,8 +871,7 @@ Socket.prototype.connect = function(options, cb) {
self.once('connect', cb);
}

for (var s = this; s !== null; s = s._parent)
timers._unrefActive(s);
this._unrefTimer();

self._connecting = true;
self.writable = true;
Expand Down Expand Up @@ -925,8 +926,7 @@ Socket.prototype.connect = function(options, cb) {
self._destroy();
});
} else {
for (var s = self; s !== null; s = s._parent)
timers._unrefActive(s);
self._unrefTimer();
connect(self,
ip,
port,
Expand Down Expand Up @@ -971,8 +971,7 @@ function afterConnect(status, handle, req, readable, writable) {
if (status == 0) {
self.readable = readable;
self.writable = writable;
for (var s = self; s !== null; s = s._parent)
timers._unrefActive(s);
self._unrefTimer();

self.emit('connect');

Expand Down