]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
added a -i switch to run ctdbd without forking
authorAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 23:44:33 +0000 (09:44 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 23:44:33 +0000 (09:44 +1000)
(This used to be ctdb commit 327df14ecd58f405fbe8b38afa2ee54a8dd0a2e4)

ctdb/common/ctdb_daemon.c
ctdb/direct/ctdbd.c
ctdb/include/ctdb.h

index 69c5005952bd2894b6abcfb23aba1584c40aea05..28ee086cc4b58544aef327d72387331e8985a03b 100644 (file)
@@ -62,7 +62,10 @@ static void ctdb_main_loop(struct ctdb_context *ctdb)
        }
 
        /* start the transport running */
-       ctdb->methods->start(ctdb);
+       if (ctdb->methods->start(ctdb) != 0) {
+               DEBUG(0,("transport failed to start!\n"));
+               ctdb_fatal(ctdb, "transport failed to start");
+       }
 
        /* go into a wait loop to allow other nodes to complete */
        event_loop_wait(ctdb->ev);
@@ -603,11 +606,14 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
                return -1;
        }
 
+#if 0
+       /* AIX doesn't like this :( */
        if (fchown(ctdb->daemon.sd, geteuid(), getegid()) != 0 ||
            fchmod(ctdb->daemon.sd, 0700) != 0) {
                DEBUG(0,("Unable to secure ctdb socket '%s', ctdb->daemon.name\n"));
                goto failed;
        }
+#endif
 
        set_non_blocking(ctdb->daemon.sd);
 
@@ -701,7 +707,7 @@ int ctdb_start(struct ctdb_context *ctdb)
 /*
   start the protocol going as a daemon
 */
-int ctdb_start_daemon(struct ctdb_context *ctdb)
+int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 {
        int res;
        struct fd_event *fde;
@@ -717,13 +723,15 @@ int ctdb_start_daemon(struct ctdb_context *ctdb)
                exit(10);
        }
 
-       if (fork()) {
+       if (do_fork && fork()) {
                return 0;
        }
 
        tdb_reopen_all(False);
 
-       setsid();
+       if (do_fork) {
+               setsid();
+       }
        block_signal(SIGPIPE);
        block_signal(SIGCHLD);
 
index 2ed1ce5ae6a8e9dfdd656363576d492d187635e4..e60e1812af8363f5d76d763bac4f36a446f35690 100644 (file)
@@ -45,10 +45,12 @@ static void block_signal(int signum)
 int main(int argc, const char *argv[])
 {
        struct ctdb_context *ctdb;
+       int interactive = 0;
 
        struct poptOption popt_options[] = {
                POPT_AUTOHELP
                POPT_CTDB_CMDLINE
+               { "interactive", 'i', POPT_ARG_NONE, &interactive, 0, "don't fork", NULL },
                POPT_TABLEEND
        };
        int opt;
@@ -90,5 +92,5 @@ int main(int argc, const char *argv[])
        }
 
        /* start the protocol running (as a child) */
-       return ctdb_start_daemon(ctdb);
+       return ctdb_start_daemon(ctdb, interactive?False:True);
 }
index 2508ea3e639504fb506981daa173c02f2e776cf1..762f7dac753b3422cb36b83fa1b7ef628b18e4b0 100644 (file)
@@ -112,7 +112,7 @@ int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
   start the ctdb protocol
 */
 int ctdb_start(struct ctdb_context *ctdb);
-int ctdb_start_daemon(struct ctdb_context *ctdb);
+int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
 
 /*
   attach to a ctdb database