]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: server: resolve state file handle leak on reload
authorIlya Shipitsin <chipitsine@gmail.com>
Wed, 15 Jul 2020 21:02:40 +0000 (02:02 +0500)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Jul 2020 02:41:32 +0000 (04:41 +0200)
During reload, server state file is read and file handle is not released
this was indepently reported in #738 and #660.

partially resolves #660. This should be backported to 2.2 and 2.1.

src/server.c

index 05b19d4e107961f7aad19052428502fa92997816..bd3dcf88685261a71f6144a1c958628728819e2b 100644 (file)
@@ -3268,6 +3268,11 @@ void apply_server_state(void)
        }
  out_load_server_state_in_tree:
 
+       if (f) {
+               fclose(f);
+               f = NULL;
+       }
+
        /* parse all proxies and load states form tree (global file) or from local file */
        for (curproxy = proxies_list; curproxy != NULL; curproxy = curproxy->next) {
                /* servers are only in backends */
@@ -3447,9 +3452,11 @@ void apply_server_state(void)
                                /* now we can proceed with server's state update */
                                srv_update_state(srv, version, srv_params);
                        }
+
+                       fileclose:
+                               fclose(f);
+
                }
-fileclose:
-               fclose(f);
        }
 
        /* now free memory allocated for the tree */