mirror of https://github.com/lukechilds/node.git
Browse Source
Only register once for listening when passing a callback to Server.listen(), this prevents servers recycled using close() from invoking the callback when Server.listen() is called later.v0.7.4-release
Simen Brekken
13 years ago
committed by
Ben Noordhuis
2 changed files with 20 additions and 1 deletions
@ -0,0 +1,19 @@ |
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var net = require('net'); |
|||
|
|||
// Server should only fire listen callback once
|
|||
var server = net.createServer(); |
|||
|
|||
server.on('close', function() { |
|||
var listeners = server.listeners('listening'); |
|||
console.log('Closed, listeners:', listeners.length); |
|||
assert.equal(0, listeners.length); |
|||
}); |
|||
|
|||
server.listen(3000, function() { |
|||
server.close(); |
|||
server.listen(3001, function() { |
|||
server.close(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue