conn->stats.request_count++;
http_server_request_ref(req);
+ i_assert(!req->delay_destroy);
+ req->delay_destroy = TRUE;
T_BEGIN {
cont = http_server_connection_handle_request(conn, req);
} T_END;
if (!cont) {
/* connection closed or request body not read yet.
the request may be destroyed now. */
- http_server_request_unref(&req);
+ if (req->destroy_pending)
+ http_server_request_destroy(&req);
+ else
+ http_server_request_unref(&req);
return;
}
if (req->req.connection_close)
conn->close_indicated = TRUE;
- http_server_request_unref(&req);
+ if (req->destroy_pending)
+ http_server_request_destroy(&req);
+ else
+ http_server_request_unref(&req);
/* client indicated it will close after this request; stop trying
to read more. */
unsigned int payload_halted:1;
unsigned int sent_100_continue:1;
+ unsigned int delay_destroy:1;
+ unsigned int destroy_pending:1;
unsigned int failed:1;
};
{
struct http_server_request *req = *_req;
- if (req->destroy_callback != NULL) {
+ if (req->delay_destroy) {
+ req->destroy_pending = TRUE;
+ } else if (req->destroy_callback != NULL) {
req->destroy_callback(req->destroy_context);
req->destroy_callback = NULL;
}