[libmultipath] plug the keywords vector leak upon "reconfigure"
authorChristophe Varoqui <root@xa-s05.(none)>
Fri, 31 Mar 2006 21:08:08 +0000 (23:08 +0200)
committerChristophe Varoqui <root@xa-s05.(none)>
Fri, 31 Mar 2006 21:08:08 +0000 (23:08 +0200)
libmultipath/config.c
libmultipath/config.h
libmultipath/parser.c
libmultipath/parser.h

index 1068755..c9d6172 100644 (file)
@@ -305,7 +305,7 @@ free_config (struct config * conf)
        free_blacklist_device(conf->blist_device);
        free_mptable(conf->mptable);
        free_hwtable(conf->hwtable);
-
+       free_keywords(conf->keywords);
        FREE(conf);
 }
 
@@ -332,6 +332,7 @@ load_config (char * file)
         * read the config file
         */
        if (filepresent(file)) {
+               set_current_keywords(&conf->keywords);
                if (init_data(file, init_keywords)) {
                        condlog(0, "error parsing config file");
                        goto out;
index 43282fe..ca022c5 100644 (file)
@@ -67,6 +67,7 @@ struct config {
        char * hwhandler;
        char * bindings_file;
 
+       vector keywords;
        vector mptable;
        vector hwtable;
 
index 9b0b5c2..385e4fb 100644 (file)
 /* local vars */
 static int sublevel = 0;
 vector keywords = NULL;
+vector *keywords_addr = NULL;
+
+void set_current_keywords (vector *k)
+{
+       keywords_addr = k;
+       keywords = NULL;
+}
 
 int
 keyword_alloc(vector keywords, char *string, int (*handler) (vector),
@@ -53,7 +60,10 @@ keyword_alloc(vector keywords, char *string, int (*handler) (vector),
 int
 install_keyword_root(char *string, int (*handler) (vector))
 {
-       return keyword_alloc(keywords, string, handler, NULL);
+       int r = keyword_alloc(keywords, string, handler, NULL);
+       if (!r)
+               *keywords_addr = keywords;
+       return r;
 }
 
 void
index f0fdd94..95d4e6f 100644 (file)
@@ -76,6 +76,7 @@ extern void *set_value(vector strvec);
 extern int process_stream(vector keywords);
 extern int init_data(char *conf_file, void (*init_keywords) (void));
 extern struct keyword * find_keyword(vector v, char * name);
+void set_current_keywords (vector *k);
 int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw,
                    void *data);