mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-logging: Move controls handling functions from common to server
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
27d1137e26
commit
e7c72588d1
@ -162,47 +162,6 @@ TDB_DATA ctdb_log_ringbuffer_collect_log(TALLOC_CTX *mem_ctx,
|
||||
return data;
|
||||
}
|
||||
|
||||
void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr)
|
||||
{
|
||||
TDB_DATA data;
|
||||
|
||||
data = ctdb_log_ringbuffer_collect_log(ctdb, log_addr->level);
|
||||
|
||||
DEBUG(DEBUG_ERR,("Send log to %d:%d\n", (int)log_addr->pnn, (int)log_addr->srvid));
|
||||
ctdb_client_send_message(ctdb, log_addr->pnn, log_addr->srvid, data);
|
||||
|
||||
if (data.dptr) {
|
||||
talloc_free(data.dptr);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
|
||||
{
|
||||
struct ctdb_get_log_addr *log_addr = (struct ctdb_get_log_addr *)addr.dptr;
|
||||
pid_t child;
|
||||
|
||||
/* spawn a child process to marshall the huge log blob and send it back
|
||||
to the ctdb tool using a MESSAGE
|
||||
*/
|
||||
child = ctdb_fork_no_free_ringbuffer(ctdb);
|
||||
if (child == (pid_t)-1) {
|
||||
DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (child == 0) {
|
||||
ctdb_set_process_name("ctdb_log_collector");
|
||||
if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
|
||||
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
|
||||
_exit(1);
|
||||
}
|
||||
ctdb_collect_log(ctdb, log_addr);
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ctdb_clear_log(struct ctdb_context *ctdb)
|
||||
{
|
||||
first_entry = 0;
|
||||
|
@ -644,5 +644,44 @@ int ctdb_init_tevent_logging(struct ctdb_context *ctdb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr)
|
||||
{
|
||||
TDB_DATA data;
|
||||
|
||||
|
||||
data = ctdb_log_ringbuffer_collect_log(ctdb, log_addr->level);
|
||||
|
||||
DEBUG(DEBUG_ERR,("Send log to %d:%d\n", (int)log_addr->pnn, (int)log_addr->srvid));
|
||||
ctdb_client_send_message(ctdb, log_addr->pnn, log_addr->srvid, data);
|
||||
|
||||
if (data.dptr) {
|
||||
talloc_free(data.dptr);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
|
||||
{
|
||||
struct ctdb_get_log_addr *log_addr = (struct ctdb_get_log_addr *)addr.dptr;
|
||||
pid_t child;
|
||||
|
||||
/* spawn a child process to marshall the huge log blob and send it back
|
||||
to the ctdb tool using a MESSAGE
|
||||
*/
|
||||
child = ctdb_fork_no_free_ringbuffer(ctdb);
|
||||
if (child == (pid_t)-1) {
|
||||
DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (child == 0) {
|
||||
ctdb_set_process_name("ctdb_log_collector");
|
||||
if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
|
||||
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
|
||||
_exit(1);
|
||||
}
|
||||
/* do logging here */
|
||||
ctdb_collect_log(ctdb, log_addr);
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user