allow multiple eventscripts using the same prefix.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 16 Oct 2008 06:57:50 +0000 (17:57 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 16 Oct 2008 06:57:50 +0000 (17:57 +1100)
this eases the pain for users that use out of tree eventscripts

server/eventscript.c

index 057bc8077cb57f2d7e44d9b951c93b9cb8429bdd..deaf750a33c2078a3309a4d009722d57ffcd0b14 100644 (file)
@@ -67,6 +67,7 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
        DIR *dir;
        struct dirent *de;
        char *script;
+       int count;
 
        if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
                /* we guarantee that only some specifically allowed event scripts are run
@@ -118,6 +119,7 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
                return -1;
        }
 
+       count = 0;
        while ((de=readdir(dir)) != NULL) {
                int namlen;
                unsigned num;
@@ -154,14 +156,8 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
                }
                
                
-               /* store the event script in the tree */                
-               script = trbt_insert32(tree, num, talloc_strdup(tree, de->d_name));
-               if (script != NULL) {
-                       DEBUG(DEBUG_CRIT,("CONFIG ERROR: Multiple event scripts with the same prefix : '%s' and '%s'. Each event script MUST have a unique prefix\n", script, de->d_name));
-                       talloc_free(tmp_ctx);
-                       closedir(dir);
-                       return -1;
-               }
+               /* store the event script in the tree */
+               trbt_insert32(tree, (num<<16)|count++, talloc_strdup(tree, de->d_name));
        }
        closedir(dir);