]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client: Made requests release payload input stream as early as possible.
authorStephan Bosch <stephan@rename-it.nl>
Sat, 12 Oct 2013 07:54:50 +0000 (10:54 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Sat, 12 Oct 2013 07:54:50 +0000 (10:54 +0300)
This prevents deadlock conditions when used for the HTTP proxy.

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

index 86a6c3c3ae71bf8222cc17afaa19a8b6d5245532..bd23a2c4d8c6088e4664ffb4628d50a5277e6afd 100644 (file)
@@ -543,6 +543,10 @@ bool http_client_request_callback(struct http_client_request *req,
                        req->callback = callback;
                        http_client_request_resubmit(req);
                        return FALSE;
+               } else {
+                       /* release payload early (prevents server/client deadlock in proxy) */
+                       if (req->payload_input != NULL)
+                               i_stream_unref(&req->payload_input);
                }
        }
        return TRUE;
@@ -563,6 +567,10 @@ http_client_request_send_error(struct http_client_request *req,
 
                http_response_init(&response, status, error);
                (void)callback(&response, req->context);
+
+               /* release payload early (prevents server/client in proxy) */
+               if (req->payload_input != NULL)
+                       i_stream_unref(&req->payload_input);
        }
 }