]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: srv-state: fix incorrect output of state file
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Jun 2016 12:51:40 +0000 (14:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 22 Jun 2016 12:51:40 +0000 (14:51 +0200)
Eric Webster reported that the state file wouldn't reload in 1.6.5
while it used to work in 1.6.4. The issue is that headers are now
missing from the output when a specific backend is dumped since
commit 4c1544d ("BUG/MEDIUM: stats: show servers state may show an
empty or incomplete result"). This patch fixes this by introducing
a dump state.

It must be backported to 1.6.

src/dumpstats.c

index d0c11f23bfc3a9d08d4b489b9b39bec11ba0f5ab..1e823d00628492eb906141a7940ea6901573cf53 100644 (file)
@@ -3200,15 +3200,22 @@ static int stats_dump_servers_state_to_buffer(struct stream_interface *si)
 
        chunk_reset(&trash);
 
-       if (!appctx->ctx.server_state.px) {
+       if (appctx->st2 == STAT_ST_INIT) {
+               if (!appctx->ctx.server_state.px)
+                       appctx->ctx.server_state.px = proxy;
+               appctx->st2 = STAT_ST_HEAD;
+       }
+
+       if (appctx->st2 == STAT_ST_HEAD) {
                chunk_printf(&trash, "%d\n# %s\n", SRV_STATE_FILE_VERSION, SRV_STATE_FILE_FIELD_NAMES);
                if (bi_putchk(si_ic(si), &trash) == -1) {
                        si_applet_cant_put(si);
                        return 0;
                }
-               appctx->ctx.server_state.px = proxy;
+               appctx->st2 = STAT_ST_INFO;
        }
 
+       /* STAT_ST_INFO */
        for (; appctx->ctx.server_state.px != NULL; appctx->ctx.server_state.px = curproxy->next) {
                curproxy = appctx->ctx.server_state.px;
                /* servers are only in backends */