]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: httpclient: destroy checks if a client was started but not stopped
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 5 Oct 2021 13:50:45 +0000 (15:50 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 6 Oct 2021 13:15:03 +0000 (15:15 +0200)
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.

include/haproxy/http_client.h
src/http_client.c

index c0d5447815258a03637eec0c40a72819d05c55d0..097997eb5379560ed8f0dccbd72cc80dc6d08ec4 100644 (file)
@@ -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 */
index 1eb3cd18a3d4d641ce91bb5483568a88da6ed992..d0a100531c59c8b1567b8ef16018df00fde2e3c3 100644 (file)
@@ -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);