]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-request - Make sure connection output is unlocked if blocking...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 25 Jan 2023 14:19:30 +0000 (15:19 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 30 Jan 2023 19:48:46 +0000 (19:48 +0000)
Otherwise, a race condition between outgoing payload transmission and receiving
the response may cause connection to hang.

src/lib-http/http-client-connection.c
src/lib-http/http-client-request.c

index df22d5a03e84887c7da90f5a1e4de5084b0d8670..371e370197b5fe489452ed037ec25512af01b4ad 100644 (file)
@@ -1445,6 +1445,7 @@ static void http_client_connection_ready(struct http_client_connection *conn)
                        struct http_response response;
 
                        conn->tunneling = TRUE;
+                       req->state = HTTP_REQUEST_STATE_WAITING;
 
                        i_zero(&response);
                        response.status = 200;
index 11aea5e2e3a773daaa61841020613035eaaad6e5..b25f768b07cd0df12b3936977c36408401677d8f 100644 (file)
@@ -1524,6 +1524,10 @@ bool http_client_request_callback(struct http_client_request *req,
        http_client_request_callback_t *callback = req->callback;
        unsigned int orig_attempts = req->attempts;
 
+       i_assert(req->state >= HTTP_REQUEST_STATE_PAYLOAD_OUT);
+       i_assert(req->conn != NULL);
+       if (req->state == HTTP_REQUEST_STATE_PAYLOAD_OUT)
+               req->conn->output_locked = FALSE;
        req->state = HTTP_REQUEST_STATE_GOT_RESPONSE;
        req->last_status = response->status;