Skip to content

Commit

Permalink
lib-http: http_server_request_unref() now always sets *req=NULL
Browse files Browse the repository at this point in the history
This makes its behavior consistent with other APIs in Dovecot.
  • Loading branch information
sirainen committed Feb 22, 2016
1 parent c3a4c93 commit 903f0b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib-http/http-server-request.c
Expand Up @@ -66,6 +66,8 @@ bool http_server_request_unref(struct http_server_request **_req)
struct http_server_connection *conn = req->conn;

i_assert(req->refcount > 0);

*_req = NULL;
if (--req->refcount > 0)
return TRUE;

Expand All @@ -84,7 +86,6 @@ bool http_server_request_unref(struct http_server_request **_req)
if (req->response != NULL)
http_server_response_free(req->response);
pool_unref(&req->pool);
*_req = NULL;
return FALSE;
}

Expand Down Expand Up @@ -449,8 +450,7 @@ http_server_istream_read(struct istream_private *stream)

ret = hsristream->read_status;

http_server_request_unref(&req);
if (req == NULL)
if (!http_server_request_unref(&req))
hsristream->req = NULL;
http_server_connection_unref(&conn);
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib-http/http-server-response.c
Expand Up @@ -405,8 +405,7 @@ http_server_response_output_payload(

/* callback may have messed with our pointer,
so unref using local variable */
http_server_request_unref(&req);
if (req == NULL)
if (!http_server_request_unref(&req))
*_resp = NULL;

http_server_connection_unref(&conn);
Expand Down

0 comments on commit 903f0b3

Please sign in to comment.