summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/cluster.js12
-rw-r--r--test/parallel/test-cluster-rr-ref.js21
2 files changed, 32 insertions, 1 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index bcde4ce1fa..9f70c0273c 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -603,12 +603,22 @@ function workerInit() {
return 0;
}
+ // XXX(bnoordhuis) Probably no point in implementing ref() and unref()
+ // because the control channel is going to keep the worker alive anyway.
+ function ref() {
+ }
+
+ function unref() {
+ }
+
// Faux handle. Mimics a TCPWrap with just enough fidelity to get away
// with it. Fools net.Server into thinking that it's backed by a real
// handle.
var handle = {
close: close,
- listen: listen
+ listen: listen,
+ ref: ref,
+ unref: unref,
};
if (message.sockname) {
handle.getsockname = getsockname; // TCP handles only.
diff --git a/test/parallel/test-cluster-rr-ref.js b/test/parallel/test-cluster-rr-ref.js
new file mode 100644
index 0000000000..606ff708e9
--- /dev/null
+++ b/test/parallel/test-cluster-rr-ref.js
@@ -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');
+ });
+ });
+}