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.
This commit is contained in:
William Lallemand 2021-10-05 15:50:45 +02:00
parent 4d60184887
commit 2a879001b5
2 changed files with 9 additions and 2 deletions

View 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 */

View 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);