From: William Lallemand Date: Tue, 5 Oct 2021 13:50:45 +0000 (+0200) Subject: MINOR: httpclient: destroy checks if a client was started but not stopped X-Git-Tag: v2.5-dev9~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a879001b5ce4b3cf3998c49a2886651e69fcf45;p=thirdparty%2Fhaproxy.git MINOR: httpclient: destroy checks if a client was started but not stopped During httpclient_destroy, add a condition in the BUG_ON which checks that the client was started before it has ended. A httpclient structure could have been created without being started. --- diff --git a/include/haproxy/http_client.h b/include/haproxy/http_client.h index c0d5447815..097997eb53 100644 --- a/include/haproxy/http_client.h +++ b/include/haproxy/http_client.h @@ -24,4 +24,11 @@ static inline int httpclient_ended(struct httpclient *hc) return !!(hc->flags & HTTPCLIENT_FS_ENDED); } +/* Return 1 if the httpclient started */ +static inline int httpclient_started(struct httpclient *hc) +{ + + return !!(hc->flags & HTTPCLIENT_FS_STARTED); +} + #endif /* ! _HAPROXY_HTTCLIENT_H */ diff --git a/src/http_client.c b/src/http_client.c index 1eb3cd18a3..d0a100531c 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -438,8 +438,8 @@ void httpclient_destroy(struct httpclient *hc) if (!hc) return; - /* we should never destroy a client which was not stopped */ - BUG_ON(!httpclient_ended(hc)); + /* we should never destroy a client which was started but not stopped */ + BUG_ON(httpclient_started(hc) && !httpclient_ended(hc)); /* request */ istfree(&hc->req.url);