Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2012-08-03 19:11:08 +0400
committerBert Belder <bertbelder@gmail.com>2012-08-03 19:11:08 +0400
commit5fdeebd94d58bf715d991d5bc63be6fff507f27d (patch)
treedeb4e6d74af44a8976c5ca07b86e403b33db1e34 /lib
parent585388bbd8d57669954a3c0c752d72bf8a3d3145 (diff)
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.js22
1 files changed, 4 insertions, 18 deletions
diff --git a/lib/net.js b/lib/net.js
index 3244a091096..861d2896633 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;