diff options
author | Fedor Indutny <fedor@indutny.com> | 2015-10-13 02:16:39 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2015-10-14 12:16:18 -0400 |
commit | ab03635fb1fd9d380d214116d2ba5bd96b2b9311 (patch) | |
tree | d198293dbe5a740d644b96f7b17bd5a920ce1c77 /src/node_http_parser.cc | |
parent | f45c31576358cf587f2551f9fbd492d9e1b55983 (diff) | |
download | android-node-v8-ab03635fb1fd9d380d214116d2ba5bd96b2b9311.tar.gz android-node-v8-ab03635fb1fd9d380d214116d2ba5bd96b2b9311.tar.bz2 android-node-v8-ab03635fb1fd9d380d214116d2ba5bd96b2b9311.zip |
http: fix stalled pipeline bug
This is a two-part fix:
- Fix pending data notification in `OutgoingMessage` to notify server
about flushed data too
- Fix pause/resume behavior for the consumed socket. `resume` event is
emitted on a next tick, and `socket._paused` can already be `true` at
this time. Pause the socket again to avoid PAUSED error on parser.
Fix: https://github.com/nodejs/node/issues/3332
PR-URL: https://github.com/nodejs/node/pull/3342
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r-- | src/node_http_parser.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 5f831ec506..ff3dfb26e5 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -484,13 +484,18 @@ class Parser : public BaseObject { if (parser->prev_alloc_cb_.is_empty()) return; - CHECK(args[0]->IsExternal()); - Local<External> stream_obj = args[0].As<External>(); - StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value()); - CHECK_NE(stream, nullptr); + // Restore stream's callbacks + if (args.Length() == 1 && args[0]->IsExternal()) { + Local<External> stream_obj = args[0].As<External>(); + StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value()); + CHECK_NE(stream, nullptr); + + stream->set_alloc_cb(parser->prev_alloc_cb_); + stream->set_read_cb(parser->prev_read_cb_); + } - stream->set_alloc_cb(parser->prev_alloc_cb_); - stream->set_read_cb(parser->prev_read_cb_); + parser->prev_alloc_cb_.clear(); + parser->prev_read_cb_.clear(); } |