Rev 301: added a -i switch to run ctdbd without forking in
http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Mon May 14 23:44:34 GMT 2007
------------------------------------------------------------
revno: 301
revision-id: tridge at samba.org-20070514234433-s9apc5wp2heogcya
parent: tridge at samba.org-20070514234403-ghdhn9vpf6fyqnhq
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Tue 2007-05-15 09:44:33 +1000
message:
added a -i switch to run ctdbd without forking
modified:
common/ctdb_daemon.c ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1
direct/ctdbd.c ctdbd.c-20070411085044-dqmhr6mfeexnyt4m-1
include/ctdb.h ctdb.h-20061117234101-o3qt14umlg9en8z0-11
=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c 2007-05-12 23:20:16 +0000
+++ b/common/ctdb_daemon.c 2007-05-14 23:44:33 +0000
@@ -62,7 +62,10 @@
}
/* 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 @@
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 @@
/*
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 @@
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);
=== modified file 'direct/ctdbd.c'
--- a/direct/ctdbd.c 2007-04-30 13:31:40 +0000
+++ b/direct/ctdbd.c 2007-05-14 23:44:33 +0000
@@ -45,10 +45,12 @@
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 @@
}
/* start the protocol running (as a child) */
- return ctdb_start_daemon(ctdb);
+ return ctdb_start_daemon(ctdb, interactive?False:True);
}
=== modified file 'include/ctdb.h'
--- a/include/ctdb.h 2007-05-12 05:15:27 +0000
+++ b/include/ctdb.h 2007-05-14 23:44:33 +0000
@@ -112,7 +112,7 @@
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
More information about the samba-cvs
mailing list