When adding a server dynamically, we observe that when a backend has a
dynamic persistence cookie, the new server has no cookie as we receive
the following HTTP header:
set-cookie: test-cookie=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/
Whereas we were expecting to receive something like the following, which
is what we receive for a server added in the config file:
set-cookie: test-cookie=abcdef1234567890; path=/

After investigating code path, it seems srv_set_dyncookie() is never
called when adding a server through CLI, it is only called when parsing
config file or using "set server bkd1/srv1 addr".

To fix this, add a call to srv_set_dyncookie() inside _srv_parse_init()
which is used on the dynamic server initialization path.
---
 src/server.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/server.c b/src/server.c
index e22b33806..c954a8de3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3306,7 +3306,9 @@ static int _srv_parse_init(struct server **srv, char 
**args, int *cur_arg,
                /*
                 * we don't need to lock the server here, because
                 * we are in the process of initializing.
-                *
+                */
+               srv_set_dyncookie(newsrv);
+               /*
                 * Note that the server is not attached into the proxy tree if
                 * this is a dynamic server.
                 */
-- 
2.34.1

Reply via email to