]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Assertion in http_client_queue_fail() was wrong.
authorStephan Bosch <stephan@rename-it.nl>
Thu, 23 Oct 2014 02:55:51 +0000 (05:55 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Thu, 23 Oct 2014 02:55:51 +0000 (05:55 +0300)
It is not guaranteed that all queue lists are empty, because new requests
can be submitted from the callbacks. Changed this into a proper invariant
check, which asserts tbat the number of requests in sub-queues add up to
the total number in the main queue.

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

index 55c178ba336ba9f2d527341a1c64896ec6376627..1aa348bdff42b0209116eba675fe16ee03985869 100644 (file)
@@ -151,10 +151,12 @@ void http_client_queue_fail(struct http_client_queue *queue,
        }
        array_clear(req_arr);
 
-       /* all queues must be empty now */
-       i_assert(array_count(&queue->delayed_requests) == 0);
-       i_assert(array_count(&queue->queued_requests) == 0);
-       i_assert(array_count(&queue->queued_urgent_requests) == 0);
+       /* all queues should be empty now... unless new requests were submitted
+          from the callback. this invariant captures it all: */
+       i_assert((array_count(&queue->delayed_requests) +
+               array_count(&queue->queued_requests) +
+               array_count(&queue->queued_urgent_requests)) ==
+               array_count(&queue->requests));
 }
 
 /*