diff options
author | Ryan Graham <r.m.graham@gmail.com> | 2015-07-02 15:26:21 -0700 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2015-08-06 10:45:59 -0700 |
commit | 5d2acfb8e5d00549152995ee671ff168d5c00e38 (patch) | |
tree | 72f8b9ab98077654f112b63835dc6ebec2bdbeb6 /lib | |
parent | 67987d9d83517e8d812f13dc5e9eca1d1b9d21ac (diff) | |
download | android-node-v8-5d2acfb8e5d00549152995ee671ff168d5c00e38.tar.gz android-node-v8-5d2acfb8e5d00549152995ee671ff168d5c00e38.tar.bz2 android-node-v8-5d2acfb8e5d00549152995ee671ff168d5c00e38.zip |
net: ensure Socket reported address is current
Any time the connection state or the underlying handle itself changes,
the socket's name (aka, local address) can change.
To deal with this we need to reset the cached sockname any time we
set or unset the internal handle or an existing handle establishes a
connection.
PR-URL: https://github.com/nodejs/io.js/pull/2095
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/net.js b/lib/net.js index 6146029d3c..10e7896784 100644 --- a/lib/net.js +++ b/lib/net.js @@ -93,6 +93,7 @@ function initSocketHandle(self) { self.destroyed = false; self.bytesRead = 0; self._bytesDispatched = 0; + self._sockname = null; // Handle creation may be deferred to bind() or connect() time. if (self._handle) { @@ -469,6 +470,7 @@ Socket.prototype._destroy = function(exception, cb) { }); this._handle.onread = noop; this._handle = null; + this._sockname = null; } // we set destroyed to true before firing error callbacks in order @@ -871,6 +873,7 @@ Socket.prototype.connect = function(options, cb) { this.destroyed = false; this._handle = null; this._peername = null; + this._sockname = null; } var self = this; @@ -1032,6 +1035,7 @@ function afterConnect(status, handle, req, readable, writable) { assert.ok(self._connecting); self._connecting = false; + self._sockname = null; if (status == 0) { self.readable = readable; |