Skip to content

Commit

Permalink
lib-http: server: Explicitly record the number of references held for…
Browse files Browse the repository at this point in the history
… a request by the application from within the callback.
  • Loading branch information
stephanbosch authored and GitLab committed Jul 4, 2017
1 parent 49c232a commit dc05b1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/lib-http/http-server-connection.c
Expand Up @@ -308,7 +308,7 @@ http_server_connection_handle_request(struct http_server_connection *conn,
struct http_server_request *req)
{
const struct http_server_settings *set = &conn->server->set;
unsigned int old_refcount, new_refcount;
unsigned int old_refcount;
struct istream *payload;
bool payload_destroyed = FALSE;

Expand Down Expand Up @@ -349,7 +349,7 @@ http_server_connection_handle_request(struct http_server_connection *conn,
return FALSE;
}
conn->in_req_callback = FALSE;
new_refcount = req->refcount;
req->callback_refcount = req->refcount - old_refcount;

if (req->req.payload != NULL) {
/* send 100 Continue when appropriate */
Expand Down Expand Up @@ -380,8 +380,7 @@ http_server_connection_handle_request(struct http_server_connection *conn,
http_server_request_submit_response(req);
}

i_assert(!payload_destroyed ||
new_refcount > old_refcount ||
i_assert(!payload_destroyed || req->callback_refcount > 0 ||
(req->response != NULL && req->response->submitted));

if (conn->incoming_payload == NULL) {
Expand Down
1 change: 1 addition & 0 deletions src/lib-http/http-server-private.h
Expand Up @@ -87,6 +87,7 @@ struct http_server_request {
pool_t pool;
unsigned int refcount;
unsigned int id;
int callback_refcount;

enum http_server_request_state state;

Expand Down

0 comments on commit dc05b1f

Please sign in to comment.