MINOR: httpclient: stop_and_destroy() ask the applet to autokill

httpclient_stop_and_destroy() tries to destroy the httpclient structure
if the client was stopped.

In the case the client wasn't stopped, it ask the client to stop itself
and to destroy the httpclient structure itself during the release of the
applet.
This commit is contained in:
William Lallemand
2021-09-28 11:00:43 +02:00
parent 739f90a6ef
commit ecb83e13eb
3 changed files with 46 additions and 4 deletions

View File

@@ -30,7 +30,12 @@ struct httpclient {
unsigned int flags; /* other flags */
};
#define HTTPCLIENT_F_ENDED 0x00000001
/* Action (FA) to do */
#define HTTPCLIENT_FA_STOP 0x00000001 /* stops the httpclient at the next IO handler call */
#define HTTPCLIENT_FA_AUTOKILL 0x00000002 /* sets the applet to destroy the httpclient struct itself */
/* status (FS) */
#define HTTPCLIENT_FS_ENDED 0x00010000 /* the httpclient is stopped */
/* States of the HTTP Client Appctx */
enum {

View File

@@ -4,6 +4,7 @@
#include <haproxy/http_client-t.h>
void httpclient_destroy(struct httpclient *hc);
void httpclient_stop_and_destroy(struct httpclient *hc);
struct httpclient *httpclient_new(void *caller, enum http_meth_t meth, struct ist url);
struct appctx *httpclient_start(struct httpclient *hc);
@@ -20,7 +21,7 @@ static inline int httpclient_data(struct httpclient *hc)
/* Return 1 if the httpclient ended and won't receive any new data */
static inline int httpclient_ended(struct httpclient *hc)
{
return !!(hc->flags & HTTPCLIENT_F_ENDED);
return !!(hc->flags & HTTPCLIENT_FS_ENDED);
}
#endif /* ! _HAPROXY_HTTCLIENT_H */