mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
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>
This commit is contained in:
parent
eee4af5c76
commit
848da80152
@ -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.
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user