[SCM] CTDB repository - branch master updated - ctdb-1.13-274-g2122982
Amitay Isaacs
amitay at samba.org
Sat Oct 6 22:28:24 MDT 2012
The branch, master has been updated
via 212298279557a2833ef0f81809b4a5cdac72ca02 (commit)
from 3a3dae4cb5ec8b4b8381a4013adda25b87641f3a (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 212298279557a2833ef0f81809b4a5cdac72ca02
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Oct 2 11:51:24 2012 +1000
util: ctdb_fork() closes all sockets opened by the main daemon
Do some other hosuekeeping including stopping tevent.
Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
client/ctdb_client.c | 24 ++++++------------------
common/ctdb_fork.c | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 18 deletions(-)
Changeset truncated at 500 lines:
diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 9162a47..d7c3031 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -4091,9 +4091,11 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb)
return 0;
}
-/* when forking the main daemon and the child process needs to connect back
- * to the daemon as a client process, this function can be used to change
- * the ctdb context from daemon into client mode
+/* When forking the main daemon and the child process needs to connect
+ * back to the daemon as a client process, this function can be used
+ * to change the ctdb context from daemon into client mode. The child
+ * process must be created using ctdb_fork() and not fork() -
+ * ctdb_fork() does some necessary housekeeping.
*/
int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
{
@@ -4105,25 +4107,11 @@ int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...
debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
va_end(ap);
- /* shutdown the transport */
- if (ctdb->methods) {
- ctdb->methods->shutdown(ctdb);
- }
-
/* get a new event context */
- talloc_free(ctdb->ev);
ctdb->ev = event_context_init(ctdb);
tevent_loop_allow_nesting(ctdb->ev);
- close(ctdb->daemon.sd);
- ctdb->daemon.sd = -1;
-
- /* the client does not need to be realtime */
- if (ctdb->do_setsched) {
- ctdb_restore_scheduler(ctdb);
- }
-
- /* initialise ctdb */
+ /* Connect to main CTDB daemon */
ret = ctdb_socket_connect(ctdb);
if (ret != 0) {
DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
diff --git a/common/ctdb_fork.c b/common/ctdb_fork.c
index 81055c5..24534e6 100644
--- a/common/ctdb_fork.c
+++ b/common/ctdb_fork.c
@@ -37,6 +37,24 @@ pid_t ctdb_fork(struct ctdb_context *ctdb)
return -1;
}
if (pid == 0) {
+ /* Close the Unix Domain socket and the TCP socket.
+ * This ensures that none of the child processes will
+ * look like the main daemon when it is not running.
+ * tevent needs to be stopped before closing sockets.
+ */
+ if (ctdb->ev != NULL) {
+ talloc_free(ctdb->ev);
+ ctdb->ev = NULL;
+ }
+ if (ctdb->daemon.sd != -1) {
+ close(ctdb->daemon.sd);
+ ctdb->daemon.sd = -1;
+ }
+ if (ctdb->methods != NULL) {
+ ctdb->methods->shutdown(ctdb);
+ }
+
+ /* The child does not need to be realtime */
if (ctdb->do_setsched) {
ctdb_restore_scheduler(ctdb);
}
--
CTDB repository
More information about the samba-cvs
mailing list