]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Hold reference to the connection while sending the next request.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Feb 2018 14:08:44 +0000 (15:08 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 12 Mar 2018 08:42:26 +0000 (10:42 +0200)
Subsequent changes may cause the connection to be destroyed while sending.

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

index 81e07c2592a42b27eeb3d1864bbb63044d846f25..2a8e1358d66ca8b774e92ece3bf24b45104ca930 100644 (file)
@@ -596,6 +596,7 @@ http_client_connection_continue_timeout(struct http_client_connection *conn)
 
 int http_client_connection_next_request(struct http_client_connection *conn)
 {
+       struct http_client_connection *tmp_conn;
        struct http_client_peer *peer = conn->peer;
        struct http_client_peer_shared *pshared = conn->ppool->peer;
        struct http_client_request *req = NULL;
@@ -631,7 +632,10 @@ int http_client_connection_next_request(struct http_client_connection *conn)
        e_debug(conn->event, "Claimed request %s",
                http_client_request_label(req));
 
-       if (http_client_request_send(req, pipelined) < 0)
+       tmp_conn = conn;
+       http_client_connection_ref(tmp_conn);
+       ret = http_client_request_send(req, pipelined);
+       if (!http_client_connection_unref(&tmp_conn) || ret < 0)
                return -1;
 
        if (req->connect_tunnel)