changeset 17999:d913fe3a926a

lib-http: client: Fixed cleanup of remaining waiting requests at connection destroy. Forgot to dereference the requests for the reference that the connection itself holds for each waiting request.
author Stephan Bosch <stephan@rename-it.nl>
date Sat, 25 Oct 2014 01:38:42 +0300
parents 9c6318786455
children 84b5e075c62c
files src/lib-http/http-client-connection.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-http/http-client-connection.c	Sat Oct 25 01:38:42 2014 +0300
+++ b/src/lib-http/http-client-connection.c	Sat Oct 25 01:38:42 2014 +0300
@@ -1265,18 +1265,24 @@
 
 	http_client_connection_disconnect(conn);
 
+	/* abort all pending requests (not supposed to happen here) */
 	if (array_is_created(&conn->request_wait_list)) {
-		/* abort all pending requests */
 		array_foreach_modifiable(&conn->request_wait_list, req) {
 			i_assert((*req)->submitted);
-			http_client_request_error(*req, HTTP_CLIENT_REQUEST_ERROR_ABORTED,
+			http_client_request_error(*req,
+				HTTP_CLIENT_REQUEST_ERROR_ABORTED,
 				"Aborting");
+			http_client_request_unref(req);
 		}
 		array_free(&conn->request_wait_list);
 	}
 	if (conn->pending_request != NULL) {
-		http_client_request_error(conn->pending_request,
-			HTTP_CLIENT_REQUEST_ERROR_ABORTED, "Aborting");
+		struct http_client_request *pending_req = conn->pending_request;
+		conn->pending_request = NULL;
+		http_client_request_error(pending_req,
+ 			HTTP_CLIENT_REQUEST_ERROR_ABORTED,
+			"Aborting");
+		http_client_request_unref(&pending_req);
 	}
 
 	if (conn->http_parser != NULL)