Fix a race condition or two in net.js
authorRyan Dahl <ry@tinyclouds.org>
Mon, 12 Apr 2010 19:34:24 +0000 (12:34 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 12 Apr 2010 19:38:11 +0000 (12:38 -0700)
commit4681e34c1e74e96f3027e88523dadf6b27a611c3
tree491c96abea347dedc3eebd4494d57fc4b21d9d08
parent62d9852c3d6ed32825abfd79645c72a66fb00e6f
Fix a race condition or two in net.js

When making a TCP connection, readyState returns 'opening' while resolving
the host. However between the resolving period and the establishing a
connection period, it would return 'closed'. This fixes it.

This change also ensures that the socket is closed before the 'end' event is
emitted in the case that the socket was previously shutdown.
lib/net.js