summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2020-05-19 01:02:30 +0300
committerAzat Khuzhin <azat@libevent.org>2020-05-19 01:06:12 +0300
commit083c6d54d50462f8112328e75bf30647b2e1789e (patch)
tree8df0d9752d68ebb20e9b4fb2eb2273617168b48b /http.c
parent70f69194eb3b19b5e41b52b17a820e1e91512560 (diff)
downloadlibevent-083c6d54d50462f8112328e75bf30647b2e1789e.tar.gz
http: fix EVHTTP_CON_AUTOFREE in case of connection error
Refs: #182
Diffstat (limited to 'http.c')
-rw-r--r--http.c8
1 files changed, 8 insertions, 0 deletions
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