From 2637b5c2610ca1f9d7889ea0d572f297b2bd5b2e Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Thu, 12 Jul 2012 21:26:04 -0400 Subject: [PATCH] ref/unref for net.Socket net.Server dgram.Socket --- lib/dgram.js | 11 +++++++++++ lib/net.js | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/dgram.js b/lib/dgram.js index 7abd0c3..d05790c 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -351,6 +351,17 @@ function onMessage(handle, slab, start, len, rinfo) { } +Socket.prototype.ref = function() { + if (this._handle) + this._handle.ref(); +}; + + +Socket.prototype.unref = function() { + if (this._handle) + this._handle.unref(); +}; + // TODO share with net_uv and others function errnoException(errorno, syscall) { var e = new Error(syscall + ' ' + errorno); diff --git a/lib/net.js b/lib/net.js index b4934e3..446b2a0 100644 --- a/lib/net.js +++ b/lib/net.js @@ -716,6 +716,19 @@ Socket.prototype.connect = function(options, cb) { }; +Socket.prototype.ref = function() { + if (this._handle) + this._handle.ref(); +}; + + +Socket.prototype.unref = function() { + if (this._handle) + this._handle.unref(); +}; + + + function afterConnect(status, handle, req, readable, writable) { var self = handle.owner; @@ -1095,6 +1108,16 @@ Server.prototype._setupSlave = function(socketList) { this._slaves.push(socketList); }; +Server.prototype.ref = function() { + if (this._handle) + this._handle.ref(); +}; + +Server.prototype.unref = function() { + if (this._handle) + this._handle.unref(); +}; + // TODO: isIP should be moved to the DNS code. Putting it here now because // this is what the legacy system did. -- 2.7.4