-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #43650 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const cluster = require('cluster'); | ||
const net = require('net'); | ||
|
||
if (cluster.isPrimary) { | ||
cluster.schedulingPolicy = cluster.SCHED_RR; | ||
cluster.fork(); | ||
} else { | ||
const server = net.createServer(common.mustNotCall()); | ||
server.listen(0, common.mustCall(() => { | ||
net.connect(server.address().port); | ||
})); | ||
process.prependListener('internalMessage', common.mustCallAtLeast((message, handle) => { | ||
if (message.act !== 'newconn') { | ||
return; | ||
} | ||
// Make the worker drops the connection, see `rr` and `onconnection` in child.js | ||
server.close(); | ||
const close = handle.close; | ||
handle.close = common.mustCall(() => { | ||
close.call(handle, common.mustCall(() => { | ||
process.exit(); | ||
})); | ||
}); | ||
})); | ||
} |