eventscript: enhance script delete race check
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:39:02 +0000 (23:09 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:39:02 +0000 (23:09 +1030)
We currently assume 127 == script removed.  The script can also return 127;
best to re-check the execution status in this case (and for 126, which will
happen if the script is non-executable).

If the script is no longer executable/not present, we ignore it.

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

index 183e0764208f6a1d768b22976a50418eb18d1eea..a4292778f15a73e33f19fb1481197c29317bf50c 100644 (file)
@@ -588,9 +588,13 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
                if (ret != -1) {
                        ret = WEXITSTATUS(ret);
                }
-               if (ret == 127) {
-                       ret = 0;
-                       DEBUG(DEBUG_ERR,("Script %s returned status 127. Someone just deleted it?\n", cmdstr));
+               if (ret == 127 || ret == 126) {
+                       /* Re-check it... */
+                       if (!check_executable(ctdb->event_script_dir,
+                                             current->name)) {
+                               ret = 0;
+                               DEBUG(DEBUG_ERR,("Script %s returned status 127. Someone just deleted it?\n", cmdstr));
+                       }
                }
  
                if (!from_user && call == CTDB_EVENT_MONITOR) {