Skip to content

Commit

Permalink
lib-http: client: queue: Do not fail claimed requests unless the queu…
Browse files Browse the repository at this point in the history
…e is being destroyed.

Before, connection failure would also abort requests already being sent on
another connection, which is premature at best.
  • Loading branch information
stephanbosch authored and villesavolainen committed Sep 7, 2018
1 parent 4675367 commit a8f17f3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib-http/http-client-queue.c
Expand Up @@ -19,8 +19,8 @@
#define TIMEOUT_CMP_MARGIN_USECS 2000

static void
http_client_queue_fail(struct http_client_queue *queue,
unsigned int status, const char *error);
http_client_queue_fail_full(struct http_client_queue *queue,
unsigned int status, const char *error, bool all);
static void
http_client_queue_set_delay_timer(struct http_client_queue *queue,
struct timeval time);
Expand Down Expand Up @@ -138,8 +138,8 @@ void http_client_queue_free(struct http_client_queue *queue)
array_free(&queue->pending_peers);

/* abort all requests */
http_client_queue_fail
(queue, HTTP_CLIENT_REQUEST_ERROR_ABORTED, "Aborted");
http_client_queue_fail_full(queue, HTTP_CLIENT_REQUEST_ERROR_ABORTED,
"Aborted", TRUE);
array_free(&queue->requests);
array_free(&queue->queued_requests);
array_free(&queue->queued_urgent_requests);
Expand All @@ -162,7 +162,7 @@ void http_client_queue_free(struct http_client_queue *queue)

static void
http_client_queue_fail_full(struct http_client_queue *queue,
unsigned int status, const char *error, bool queued_only)
unsigned int status, const char *error, bool all)
{
ARRAY_TYPE(http_client_request) *req_arr, treqs;
struct http_client_request **req_idx;
Expand All @@ -176,7 +176,7 @@ http_client_queue_fail_full(struct http_client_queue *queue,
struct http_client_request *req = *req_idx;

i_assert(req->state >= HTTP_REQUEST_STATE_QUEUED);
if (queued_only &&
if (!all &&
req->state != HTTP_REQUEST_STATE_QUEUED)
retained++;
else
Expand Down Expand Up @@ -437,9 +437,8 @@ http_client_queue_host_lookup_done(struct http_client_queue *queue)
void http_client_queue_host_lookup_failure(
struct http_client_queue *queue, const char *error)
{
http_client_queue_fail_full(queue,
HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED,
error, TRUE);
http_client_queue_fail(queue,
HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED, error);
}

void
Expand Down

0 comments on commit a8f17f3

Please sign in to comment.