net: use close callback, not process.nextTick
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 6 Mar 2013 15:15:17 +0000 (16:15 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 6 Mar 2013 15:15:18 +0000 (16:15 +0100)
commitfb3ec32b0ea5e42f6a9a8f0d5f43779f92cfac4a
tree129d0e8cba32085dc9715c1449ce1dd97e3f7d28
parent958ab661cbede92470ffd47b23607c61f5e61e17
net: use close callback, not process.nextTick

Don't emit the 'close' event with process.nextTick.

Closing a handle is an operation that usually *but not always* completes
on the next tick of the event loop, hence using process.nextTick is not
reliable.

Use a proper handle close callback and emit the 'close' event from
inside the callback.

Update tests that depend on the intricacies of the old model.

Fixes #3459.
lib/net.js
test/simple/test-http-agent-destroyed-socket.js
test/simple/test-net-server-close.js
test/simple/test-process-active-wraps.js