diff options
author | Bert Belder <bertbelder@gmail.com> | 2012-08-03 17:11:08 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2012-08-03 17:11:08 +0200 |
commit | 5fdeebd94d58bf715d991d5bc63be6fff507f27d (patch) | |
tree | deb4e6d74af44a8976c5ca07b86e403b33db1e34 /lib | |
parent | 585388bbd8d57669954a3c0c752d72bf8a3d3145 (diff) | |
download | nodejs-5fdeebd94d58bf715d991d5bc63be6fff507f27d.tar.gz nodejs-5fdeebd94d58bf715d991d5bc63be6fff507f27d.tar.bz2 nodejs-5fdeebd94d58bf715d991d5bc63be6fff507f27d.zip |
net: make pause work with connecting sockets
This fixes the problem that calling pause() on a socket would not
actually prevent 'data' events from being emitted. It also replaces
the existing test by a more elaborate one.
Ref: #3118
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net.js | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/lib/net.js b/lib/net.js index 3244a0910..861d28966 100644 --- a/lib/net.js +++ b/lib/net.js @@ -236,11 +236,7 @@ Object.defineProperty(Socket.prototype, 'bufferSize', { Socket.prototype.pause = function() { this._paused = true; - if (this._connecting) { - // will actually pause once the handle is established. - return; - } - if (this._handle) { + if (this._handle && !this._connecting) { this._handle.readStop(); } }; @@ -248,11 +244,7 @@ Socket.prototype.pause = function() { Socket.prototype.resume = function() { this._paused = false; - if (this._connecting) { - // will actually resume once the handle is established. - return; - } - if (this._handle) { + if (this._handle && !this._connecting) { this._handle.readStart(); } }; @@ -737,18 +729,12 @@ function afterConnect(status, handle, req, readable, writable) { assert.ok(self._connecting); self._connecting = false; - // now that we're connected, process any pending pause state. - if (self._paused) { - self._paused = false; - self.pause(); - } - if (status == 0) { self.readable = readable; self.writable = writable; timers.active(self); - if (self.readable) { + if (self.readable && !self._paused) { handle.readStart(); } @@ -1041,7 +1027,7 @@ function onconnection(clientHandle) { }); socket.readable = socket.writable = true; - socket.resume(); + clientHandle.readStart(); self._connections++; socket.server = self; |