eventscript: simplify ctdb_run_event_script loop
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:43:12 +0000 (23:13 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:43:12 +0000 (23:13 +1030)
If we break, we avoid cut & paste code inside the loop.  Need to initialize
ret to 0 for the "no scripts" case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
server/eventscript.c

index 5f46b38ada4019a46a5e66c2f237f087c663c692..bd42ed6d524976d9479e55692f546cf40e339b17 100644 (file)
@@ -445,7 +445,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
                                 const char *options)
 {
        char *cmdstr;
-       int ret;
+       int ret = 0;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct ctdb_script_list *scripts, *current;
 
@@ -585,17 +585,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
 
                /* return an error if the script failed */
                if (ret != 0) {
-                       DEBUG(DEBUG_ERR,("Event script %s failed with error %d\n", cmdstr, ret));
-                       if (!from_user && call == CTDB_EVENT_MONITOR) {
-                               if (ctdb_ctrl_event_script_finished(ctdb) != 0) {
-                                       DEBUG(DEBUG_ERR,(__location__ " Failed to finish event script monitoring\n"));
-                                       talloc_free(tmp_ctx);
-                                       return -1;
-                               }
-                       }
-
-                       talloc_free(tmp_ctx);
-                       return ret;
+                       break;
                }
        }
 
@@ -611,7 +601,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
        }
 
        talloc_free(tmp_ctx);
-       return 0;
+       return ret;
 }
 
 /* called when child is finished */