]> 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)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 16 Jun 2017 06:16:23 +0000 (09:16 +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 91238c1e562c2ac4ebb7ea14316d8b592bd43523..35e3efb75e8e6a730df50980b6739dd4e80adfd2 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 afeaedb08edb31194e661d4bdb77949a8a3400b3..9c3a3dc31a7cd04f47e50ea853d1ee682332b264 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 5ebfc3500eebe083c1dee8b48cdfaeaed368502b..dd8bec586eefb6b293bb1dc1df38369c95c3bd80 100644 (file)
@@ -299,6 +299,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);
 }