Skip to content

[5.0] fix crash/UB when exceeding http-max-requests-in-flight#2209

Merged
spoonincode merged 1 commit intorelease/5.0from
max-requests_fix_50
Feb 5, 2024
Merged

[5.0] fix crash/UB when exceeding http-max-requests-in-flight#2209
spoonincode merged 1 commit intorelease/5.0from
max-requests_fix_50

Conversation

@spoonincode
Copy link
Contributor

When verify_max_requests_in_flight() indicates we've exceeded max requests in flight, send_busy_response(), via send_response(), queues up an async_write() on the socket. But once this async_write() returns, do_eof() would be called which closes the socket while operations are pending. This causes bad things to happen.

Instead, set the keep_alive(false) on the response, which flags needs_eof() so that,

bool close = !(plugin_state_->keep_alive) || res_->need_eof();

will be set to true, which means the socket will be properly disposed of once the async_write() completes,
if(close) {
// This means we should close the connection, usually because
// the response indicated the "Connection: close" semantic.
return do_eof();
}

@spoonincode spoonincode merged commit 6e3c378 into release/5.0 Feb 5, 2024
@spoonincode spoonincode deleted the max-requests_fix_50 branch February 5, 2024 22:21
@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: BUG
summary: Guard against errors when exceeding http-max-requests-in-flight
Note:end

@bhazzard bhazzard added this to the Leap v5.0.1 milestone Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants