-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src,lib: the handle keeps loop alive in cluster rr mode
PR-URL: #46161 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
- Loading branch information
Showing
4 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const cluster = require('cluster'); | ||
const net = require('net'); | ||
|
||
cluster.schedulingPolicy = cluster.SCHED_RR; | ||
|
||
if (cluster.isPrimary) { | ||
const worker = cluster.fork(); | ||
worker.on('exit', common.mustCall()); | ||
} else { | ||
const server = net.createServer(common.mustNotCall()); | ||
server.listen(0, common.mustCall(() => { | ||
process.channel.unref(); | ||
server.close(); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const cluster = require('cluster'); | ||
const net = require('net'); | ||
const assert = require('assert'); | ||
|
||
cluster.schedulingPolicy = cluster.SCHED_RR; | ||
|
||
if (cluster.isPrimary) { | ||
let exited = false; | ||
const worker = cluster.fork(); | ||
worker.on('exit', () => { | ||
exited = true; | ||
}); | ||
setTimeout(() => { | ||
assert.ok(!exited); | ||
worker.kill(); | ||
}, 3000); | ||
} else { | ||
const server = net.createServer(common.mustNotCall()); | ||
server.listen(0, common.mustCall(() => process.channel.unref())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const cluster = require('cluster'); | ||
const net = require('net'); | ||
|
||
cluster.schedulingPolicy = cluster.SCHED_RR; | ||
|
||
if (cluster.isPrimary) { | ||
const worker = cluster.fork(); | ||
worker.on('exit', common.mustCall()); | ||
} else { | ||
const server = net.createServer(common.mustNotCall()); | ||
server.listen(0, common.mustCall(() => { | ||
server.ref(); | ||
server.unref(); | ||
process.channel.unref(); | ||
})); | ||
server.unref(); | ||
} |