]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: Add functions to backup and restore registered sections
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Oct 2016 09:09:44 +0000 (11:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Nov 2016 21:56:59 +0000 (22:56 +0100)
This feature will be used by the stream processing offload engine (SPOE) to
parse dedicated configuration files without mixing HAProxy sections with SPOE
sections.

So, here we can back up all sections known by HAProxy, unregister all of them
and add new ones, dedicted to the SPOE. Once the SPOE configuration file parsed,
we can roll back all changes by restoring HAProxy sections.

include/common/cfgparse.h
src/cfgparse.c

index 39e8a4c5b28025508aa21a057adb285a7ede44ae..9f432ad3992f8affce22766596d66586f688af87 100644 (file)
@@ -74,6 +74,8 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
 int cfg_register_section(char *section_name,
                          int (*section_parser)(const char *, int, char **, int));
 void cfg_unregister_sections(void);
+void cfg_backup_sections(struct list *backup_sections);
+void cfg_restore_sections(struct list *backup_sections);
 int warnif_misplaced_tcp_conn(struct proxy *proxy, const char *file, int line, const char *arg);
 int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg);
 int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg);
index 83accbeb9b84c8540508938ea120339d6fb69f27..5e849699b5ea45afa5fecc8b7010edd9065e5d07 100644 (file)
@@ -9258,6 +9258,26 @@ void cfg_unregister_sections(void)
        }
 }
 
+void cfg_backup_sections(struct list *backup_sections)
+{
+       struct cfg_section *cs, *ics;
+
+       list_for_each_entry_safe(cs, ics, &sections, list) {
+               LIST_DEL(&cs->list);
+               LIST_ADDQ(backup_sections, &cs->list);
+       }
+}
+
+void cfg_restore_sections(struct list *backup_sections)
+{
+       struct cfg_section *cs, *ics;
+
+       list_for_each_entry_safe(cs, ics, backup_sections, list) {
+               LIST_DEL(&cs->list);
+               LIST_ADDQ(&sections, &cs->list);
+       }
+}
+
 __attribute__((constructor))
 static void cfgparse_init(void)
 {