mirror of https://github.com/lukechilds/node.git
Browse Source
Add ref() and unref() stub methods to the faux handle in round-robin mode. Fixes the following TypeError when calling `server.unref()` in the worker: net.js:1521 this._handle.unref(); ^ TypeError: this._handle.unref is not a function at Server.unref (net.js:1521:18) No actual reference counting is implemented. It would effectively be a no-op because the control channel would still keep the worker alive. Fixes: https://github.com/nodejs/node/issues/73 PR-URL: https://github.com/nodejs/io.js/pull/2274 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>v4.0.0-rc
Ben Noordhuis
10 years ago
2 changed files with 32 additions and 1 deletions
@ -0,0 +1,21 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const cluster = require('cluster'); |
|||
const net = require('net'); |
|||
|
|||
if (cluster.isMaster) { |
|||
cluster.fork().on('message', function(msg) { |
|||
if (msg === 'done') this.kill(); |
|||
}); |
|||
} else { |
|||
const server = net.createServer(assert.fail); |
|||
server.listen(common.PORT, function() { |
|||
server.unref(); |
|||
server.ref(); |
|||
server.close(function() { |
|||
process.send('done'); |
|||
}); |
|||
}); |
|||
} |
Loading…
Reference in new issue