Browse Source

Fix GH-746 process.stdin.destroy() breaks http server

v0.7.4-release
koichik 14 years ago
committed by Ryan Dahl
parent
commit
113b1e6e0c
  1. 4
      lib/net.js
  2. 27
      test/simple/test-net-server-on-fd-0.js

4
lib/net.js

@ -877,7 +877,7 @@ function Server(/* [ options, ] listener */) {
self.watcher.stop();
}
while (self.fd) {
while (typeof self.fd === 'number') {
try {
var peerInfo = accept(self.fd);
} catch (e) {
@ -1098,7 +1098,7 @@ Server.prototype.address = function() {
Server.prototype.close = function() {
var self = this;
if (!self.fd) throw new Error('Not running');
if (typeof self.fd !== 'number') throw new Error('Not running');
self.watcher.stop();

27
test/simple/test-net-server-on-fd-0.js

@ -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…
Cancel
Save