From: Azat Khuzhin Date: Mon, 18 May 2020 22:02:30 +0000 (+0300) Subject: http: fix EVHTTP_CON_AUTOFREE in case of connection error X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=083c6d54d50462f8112328e75bf30647b2e1789e;p=libevent http: fix EVHTTP_CON_AUTOFREE in case of connection error Refs: #182 --- diff --git a/http.c b/http.c index 09feb196..15aac661 100644 --- a/http.c +++ b/http.c @@ -1492,8 +1492,10 @@ static void evhttp_connection_cb_cleanup(struct evhttp_connection *evcon) { struct evcon_requestq requests; + EVUTIL_ASSERT(evcon->flags & EVHTTP_CON_OUTGOING); evhttp_connection_reset_(evcon); + if (evcon->retry_max < 0 || evcon->retry_cnt < evcon->retry_max) { struct timeval tv_retry = evcon->initial_retry_timeout; int i; @@ -1539,6 +1541,12 @@ evhttp_connection_cb_cleanup(struct evhttp_connection *evcon) request->cb(request, request->cb_arg); evhttp_request_free_auto(request); } + + if (TAILQ_FIRST(&evcon->requests) == NULL + && (evcon->flags & EVHTTP_CON_AUTOFREE)) { + evhttp_connection_free(evcon); + } + } static void