]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker/httpclient: initialization skipped by accident in mworker mode
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 17 Oct 2024 10:09:05 +0000 (12:09 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 17 Oct 2024 10:16:35 +0000 (12:16 +0200)
Since commit fe75c1e12da061 ("MEDIUM: startup: remove
MODE_MWORKER_WAIT") the MODE_MWORKER_WAIT constant disappearded. The
initialization of the httpclient proxy was conditionned by this
constant.

The proxy must be created in mworker mode, but only in the worker not in
the master. It was currently completely disabled in both the master and
the worker provoking a NULL dereference upon httpclient usage.

No backport needed.

src/http_client.c

index f137a6e3bed8711e06596e486661863b85af8775..a1b976ca0efe4dc01219783cb0159dcbf42a19da 100644 (file)
@@ -1208,7 +1208,8 @@ struct proxy *httpclient_create_proxy(const char *id)
        struct server *srv_ssl = NULL;
 #endif
 
-       if (global.mode & MODE_MWORKER)
+       /* the httpclient is not usable in the master process */
+       if (master)
                return ERR_NONE;
 
        px = alloc_new_proxy(id, PR_CAP_LISTEN|PR_CAP_INT|PR_CAP_HTTPCLIENT, &errmsg);
@@ -1345,8 +1346,11 @@ err:
  */
 static int httpclient_precheck()
 {
-       /* initialize the default httpclient_proxy which is used for the CLI and the lua */
+       /* the httpclient is not usable in the master process */
+       if (master)
+               return ERR_NONE;
 
+       /* initialize the default httpclient_proxy which is used for the CLI and the lua */
        httpclient_proxy = httpclient_create_proxy("<HTTPCLIENT>");
        if (!httpclient_proxy)
                return ERR_RETRYABLE;
@@ -1365,7 +1369,8 @@ static int httpclient_postcheck_proxy(struct proxy *curproxy)
        struct server *srv_ssl = NULL;
 #endif
 
-       if (global.mode & MODE_MWORKER)
+       /* the httpclient is not usable in the master process */
+       if (master)
                return ERR_NONE;
 
        if (!(curproxy->cap & PR_CAP_HTTPCLIENT))