void http_client_connection_request_destroyed(
struct http_client_connection *conn, struct http_client_request *req)
{
- struct istream *payload = conn->incoming_payload;
+ struct istream *payload;
i_assert(req->conn == conn);
if (conn->pending_request != req)
http_client_connection_debug(conn,
"Pending request destroyed prematurely");
- if (payload == NULL)
+ payload = conn->incoming_payload;
+ if (payload == NULL) {
+ /* payload already gone */
return;
+ }
+
+ /* destroy the payload, so that the timeout istream is closed */
i_stream_ref(payload);
i_stream_destroy(&payload);
+
+ payload = conn->incoming_payload;
+ if (payload == NULL) {
+ /* not going to happen, but check for it anyway */
+ return;
+ }
+
+ /* the application still holds a reference to the payload stream, but it
+ is closed and we don't care about it anymore, so act as though it is
+ destroyed. */
+ i_stream_remove_destroy_callback(payload,
+ http_client_payload_destroyed);
+ http_client_payload_destroyed(req);
}
static bool