fix(esp_http_server): prevent concurrent access to socket used in async http requests

This commit is contained in:
Friedolin Gröger
2024-07-16 10:46:50 +02:00
parent 5ca9f2a49a
commit 4a7f371056
3 changed files with 11 additions and 3 deletions

View File

@@ -631,9 +631,11 @@ esp_err_t httpd_req_async_handler_begin(httpd_req_t *r, httpd_req_t **out)
}
memcpy(async_aux->resp_hdrs, r_aux->resp_hdrs, hd->config.max_resp_headers * sizeof(struct resp_hdr));
// Prevent the main thread from reading the rest of the request after the handler returns.
r_aux->remaining_len = 0;
// mark socket as "in use"
struct httpd_req_aux *ra = r->aux;
ra->sd->for_async_req = true;
r_aux->sd->for_async_req = true;
*out = async;