ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
authorAmitay Isaacs <amitay@gmail.com>
Wed, 11 Nov 2015 03:18:51 +0000 (14:18 +1100)
committerMartin Schwenke <martins@samba.org>
Sun, 15 Nov 2015 23:46:14 +0000 (00:46 +0100)
This function can only called from ctdb daemon.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h
ctdb/include/ctdb_private.h
ctdb/server/ctdb_daemon.c

index c655ffd9eb46115942d86a4012ce849589e7328a..f9686cca659236f4f6bb677b31357be93c40bf43 100644 (file)
@@ -4388,38 +4388,6 @@ 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.  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, ...)
-{
-       int ret;
-       va_list ap;
-
-       /* Add extra information so we can identify this in the logs */
-       va_start(ap, fmt);
-       debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
-       va_end(ap);
-
-       /* get a new event context */
-       ctdb->ev = tevent_context_init(ctdb);
-       tevent_loop_allow_nesting(ctdb->ev);
-
-       /* Connect to main CTDB daemon */
-       ret = ctdb_socket_connect(ctdb);
-       if (ret != 0) {
-               DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
-               return -1;
-       }
-
-       ctdb->can_send_controls = true;
-
-       return 0;
-}
-
 /*
   get the status of running the monitor eventscripts: NULL means never run.
  */
index 6b5ad6629f1029e0fb2d245c4ad3ad6d361e0080..e81d7bb6615c98d43f592cbedc8415cf30118df0 100644 (file)
@@ -561,9 +561,6 @@ int ctdb_transaction_cancel(struct ctdb_transaction_handle *h);
 
 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
 
-int switch_from_server_to_client(struct ctdb_context *ctdb,
-                                const char *fmt, ...);
-
 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
                              struct timeval timeout, uint32_t destnode,
                              TALLOC_CTX *mem_ctx,
index 100b036c57631fc0c9a8b2836957fa1426bf0862..114d7c468c8f6ffabc766af9cac5aaa4786936a8 100644 (file)
@@ -644,6 +644,9 @@ int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
 
 void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
 
+int switch_from_server_to_client(struct ctdb_context *ctdb,
+                                const char *fmt, ...);
+
 /* from server/ctdb_freeze.c */
 
 int32_t ctdb_control_db_freeze(struct ctdb_context *ctdb,
index 41fc5e47c4ba0810a77ac96cae1525b8801f8c63..4abec4e1c0d023ef8c79197149caef9e53945001 100644 (file)
@@ -1826,3 +1826,35 @@ void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code)
        DEBUG(DEBUG_NOTICE,("Shutdown sequence complete, exiting.\n"));
        exit(exit_code);
 }
+
+/* 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, ...)
+{
+       int ret;
+       va_list ap;
+
+       /* Add extra information so we can identify this in the logs */
+       va_start(ap, fmt);
+       debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
+       va_end(ap);
+
+       /* get a new event context */
+       ctdb->ev = tevent_context_init(ctdb);
+       tevent_loop_allow_nesting(ctdb->ev);
+
+       /* Connect to main CTDB daemon */
+       ret = ctdb_socket_connect(ctdb);
+       if (ret != 0) {
+               DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
+               return -1;
+       }
+
+       ctdb->can_send_controls = true;
+
+       return 0;
+}