summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-06-06 15:43:22 +1000
committerMartin Schwenke <martins@samba.org>2014-06-12 05:40:10 +0200
commite7c72588d187f9505444f48a1c5b19e47b15ccd9 (patch)
tree35c23d65b437d782e32357642456c7747ebbb0e3 /ctdb
parent27d1137e26703d7fa5fba638e56961384a140eb2 (diff)
downloadsamba-e7c72588d187f9505444f48a1c5b19e47b15ccd9.tar.gz
samba-e7c72588d187f9505444f48a1c5b19e47b15ccd9.tar.xz
samba-e7c72588d187f9505444f48a1c5b19e47b15ccd9.zip
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>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/ctdb_logging.c41
-rw-r--r--ctdb/server/ctdb_logging.c41
2 files changed, 40 insertions, 42 deletions
diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c
index 03ac2689581..6dd1a385daa 100644
--- a/ctdb/common/ctdb_logging.c
+++ b/ctdb/common/ctdb_logging.c
@@ -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;
diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c
index d33419177bb..f22c9f30ee9 100644
--- a/ctdb/server/ctdb_logging.c
+++ b/ctdb/server/ctdb_logging.c
@@ -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;
+}