]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Explicitly destroy the response payload timeout stream when the...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 24 May 2017 17:08:43 +0000 (19:08 +0200)
committerGitLab <gitlab@git.dovecot.net>
Fri, 26 May 2017 09:26:45 +0000 (12:26 +0300)
This way, the timeout is stopped.
This caused ioloop panics.

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

index bf2d9c744d9fac3c28782df6fc21f25b5978cc0a..f8f6391676648d3b58dc8c1c9117ea501a9f6ca7 100644 (file)
@@ -643,6 +643,24 @@ static void http_client_payload_destroyed(struct http_client_request *req)
                http_client_peer_trigger_request_handler(conn->peer);
 }
 
+void http_client_connection_request_destroyed(
+       struct http_client_connection *conn, struct http_client_request *req)
+{
+       struct istream *payload = conn->incoming_payload;
+
+       i_assert(req->conn == conn);
+       if (conn->pending_request != req)
+               return;
+
+       http_client_connection_debug(conn,
+               "Pending request destroyed prematurely");
+
+       if (payload == NULL)
+               return;
+       i_stream_ref(payload);
+       i_stream_destroy(&payload);
+}
+
 static bool
 http_client_connection_return_response(
        struct http_client_connection *conn,
index 24d76867f0efd282a5a0a77e1b329d4a687019d5..37cdffbd415e1442575115c625d7885f834186fb 100644 (file)
@@ -413,6 +413,8 @@ bool http_client_connection_unref(struct http_client_connection **_conn);
 void http_client_connection_close(struct http_client_connection **_conn);
 
 void http_client_connection_peer_closed(struct http_client_connection **_conn);
+void http_client_connection_request_destroyed(
+       struct http_client_connection *conn, struct http_client_request *req);
 
 int http_client_connection_output(struct http_client_connection *conn);
 void http_client_connection_start_request_timeout(
index 6e102eee5cb0dc748c5ab97685e9eb67fb657fe2..21c0a90917ad430e3b4ff91ccc112a24a9c2dff1 100644 (file)
@@ -300,6 +300,10 @@ void http_client_request_destroy(struct http_client_request **_req)
                req->destroy_callback = NULL;
                callback(req->destroy_context);
        }
+
+       if (req->conn != NULL)
+               http_client_connection_request_destroyed(req->conn, req);
+
        http_client_request_remove(req);
        http_client_request_unref(&req);
 }