mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
When pipelined requests arrive in one TCP segment, llhttp_execute() parses them all in a single call. If a synchronous 'close' event handler invokes freeParser() mid-execution, cleanParser() nulls out parser state while llhttp_execute() is still on the stack, crashing on the next callback. Add an is_being_freed_ flag that freeParser() sets via parser.markFreed() before cleaning state. Proxy::Raw checks the flag before every callback and returns HPE_USER to abort execution early if set. PR-URL: https://github.com/nodejs/node/pull/62095 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
24 lines
738 B
JavaScript
24 lines
738 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { createServer } = require('http');
|
|
const { connect } = require('net');
|
|
|
|
// Regression test: ensure llhttp_execute() is aborted when freeParser() is
|
|
// called synchronously during parsing of pipelined requests.
|
|
const server = createServer(common.mustCall((req, res) => {
|
|
req.socket.emit('close');
|
|
res.end();
|
|
}, 1));
|
|
|
|
server.unref();
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
// Two pipelined requests in one write, processed by a single llhttp_execute().
|
|
const client = connect(server.address().port);
|
|
client.end(
|
|
'GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n' +
|
|
'GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n',
|
|
);
|
|
}));
|