diff --git a/lib/spdy/protocol/parser.js b/lib/spdy/protocol/parser.js index 56376a9..f26df4c 100644 --- a/lib/spdy/protocol/parser.js +++ b/lib/spdy/protocol/parser.js @@ -22,7 +22,6 @@ if (legacy) { function Parser(connection) { DuplexStream.call(this); - this.drained = true; this.paused = false; this.buffer = []; this.buffered = 0; @@ -80,6 +79,7 @@ Parser.prototype._write = function write(data, encoding, cb) { // Notify caller about state (for piping) if (this.paused) { this.needDrain = true; + cb(); return false; } diff --git a/lib/spdy/scheduler.js b/lib/spdy/scheduler.js index 80733a0..f22a601 100644 --- a/lib/spdy/scheduler.js +++ b/lib/spdy/scheduler.js @@ -93,7 +93,7 @@ Scheduler.prototype.tick = function tick(cb) { this.connection.cork(); this._corked = true; } - if (this.connection._spdyState.parser.drained) { + if (!this.connection._spdyState.parser.needDrain) { utils.nextTick(this._tickListener); } else { this.connection._spdyState.parser.once('drain', this._tickListener); diff --git a/test/unit/stream-test.js b/test/unit/stream-test.js index daa9b75..a9443a6 100644 --- a/test/unit/stream-test.js +++ b/test/unit/stream-test.js @@ -323,7 +323,7 @@ suite('A SPDY Server / Stream', function() { test('timing out', function(done) { var data = ''; - pair.server.req.socket.setTimeout(500); + pair.server.req.socket.setTimeout(300); pair.client.req.on('error', function() { done(); }); @@ -333,13 +333,13 @@ suite('A SPDY Server / Stream', function() { var data = ''; var chunks = 0; - pair.server.req.socket.setTimeout(300); + pair.server.req.socket.setTimeout(150); setTimeout(function() { pair.server.res.write('ok1'); setTimeout(function() { pair.server.res.write('ok2'); - }, 250); - }, 250); + }, 100); + }, 100); pair.client.res.on('data', function(chunk) { chunk = chunk.toString();