Fix GH-746 process.stdin.destroy() breaks http server
This commit is contained in:
parent
2a61e1cd49
commit
113b1e6e0c
@ -877,7 +877,7 @@ function Server(/* [ options, ] listener */) {
|
|||||||
self.watcher.stop();
|
self.watcher.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (self.fd) {
|
while (typeof self.fd === 'number') {
|
||||||
try {
|
try {
|
||||||
var peerInfo = accept(self.fd);
|
var peerInfo = accept(self.fd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -1098,7 +1098,7 @@ Server.prototype.address = function() {
|
|||||||
|
|
||||||
Server.prototype.close = function() {
|
Server.prototype.close = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!self.fd) throw new Error('Not running');
|
if (typeof self.fd !== 'number') throw new Error('Not running');
|
||||||
|
|
||||||
self.watcher.stop();
|
self.watcher.stop();
|
||||||
|
|
||||||
|
27
test/simple/test-net-server-on-fd-0.js
Normal file
27
test/simple/test-net-server-on-fd-0.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
var common = require('../common');
|
||||||
|
var assert = require('assert');
|
||||||
|
var net = require('net');
|
||||||
|
|
||||||
|
process.stdin.destroy();
|
||||||
|
|
||||||
|
var accepted = null;
|
||||||
|
var server = net.createServer(function(socket) {
|
||||||
|
console.log('accepted');
|
||||||
|
accepted = socket;
|
||||||
|
socket.end();
|
||||||
|
server.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
server.listen(common.PORT, function() {
|
||||||
|
console.log('listening...');
|
||||||
|
assert.equal(server.fd, 0);
|
||||||
|
|
||||||
|
net.createConnection(common.PORT);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
process.on('exit', function() {
|
||||||
|
assert.ok(accepted);
|
||||||
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user