ref/unref for net.Socket net.Server dgram.Socket

This commit is contained in:
Timothy J Fontaine 2012-07-12 21:26:04 -04:00 committed by Bert Belder
parent 19d43f852e
commit 2637b5c261
2 changed files with 34 additions and 0 deletions

View File

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

View File

@ -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.