-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child_process: null
channel handle on close
#3041
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const cluster = require('cluster'); | ||
const net = require('net'); | ||
const util = require('util'); | ||
|
||
if (!cluster.isMaster) { | ||
// Exit on first received handle to leave the queue non-empty in master | ||
process.on('message', function() { | ||
process.exit(1); | ||
}); | ||
return; | ||
} | ||
|
||
var server = net.createServer(function(s) { | ||
setTimeout(function() { | ||
s.destroy(); | ||
}, 100); | ||
}).listen(common.PORT, function() { | ||
var worker = cluster.fork(); | ||
|
||
function send(callback) { | ||
var s = net.connect(common.PORT, function() { | ||
worker.send({}, s, callback); | ||
}); | ||
} | ||
|
||
worker.process.once('close', common.mustCall(function() { | ||
// Otherwise the crash on `_channel.fd` access may happen | ||
assert(worker.process._channel === null); | ||
server.close(); | ||
})); | ||
|
||
// Queue up several handles, to make `process.disconnect()` wait | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the surrounding code, without this loop also the assertion in close event will be satisfied, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The worker won't exit without the loop. It expect the message to come. Sending multiple items is crucial to make this test fail on the unpatched node. |
||
for (var i = 0; i < 100; i++) | ||
send(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common should be loaded first. It has some global pollution detection logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.