mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
src: unconsume stream fix in internal http impl
When emitting a 'connection' event on a httpServer, the function connectionListener is called. Then, a new parser is created, and 'consume' method is called on the socket's externalStream. However, if this stream was already consumed and unconsumed, the process crashes with a cpp assert from the 'Consume' method in stream_base.h. This commit makes sure that no SIGABRT will be raised and the process will stay alive (after emitting the socket). PR-URL: https://github.com/nodejs/node/pull/11015 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
10b687b58b
commit
3e3bfc57d9
2 files changed
+25
-1
No files matched your search
+3
-1
@@ -328,9 +328,11 @@ function connectionListener(socket) {
|
||||
// Override on to unconsume on `data`, `readable` listeners
|
||||
socket.on = socketOnWrap;
|
||||
|
||||
// We only consume the socket if it has never been consumed before.
|
||||
var external = socket._handle._externalStream;
|
||||
if (external) {
|
||||
if (!socket._handle._consumed && external) {
|
||||
parser._consumed = true;
|
||||
socket._handle._consumed = true;
|
||||
parser.consume(external);
|
||||
}
|
||||
parser[kOnExecute] =
|
||||
|
||||
Reference in new issue
Block a user