1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdbd: Set process names for child processes

This helps distinguish processes in process list in top, perf, etc.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 2493f57ce268d6fe7e4c40a87852c347fd60d29e)
This commit is contained in:
Amitay Isaacs 2013-07-09 12:32:53 +10:00
parent 500b26e48f
commit 1c21f37e57
11 changed files with 14 additions and 1 deletions

View File

@ -166,6 +166,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
}
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);

View File

@ -1645,6 +1645,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
close(rc->fd[0]);
debug_extra = talloc_asprintf(NULL, "revokechild-%s:", ctdb_db->db_name);
ctdb_set_process_name("ctdb_revokechild");
if (switch_from_server_to_client(ctdb, "revokechild-%s", ctdb_db->db_name) != 0) {
DEBUG(DEBUG_ERR,("Failed to switch from server to client for revokechild process\n"));
c = 1;

View File

@ -141,6 +141,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
ctdb->ev = event_context_init(NULL);
syslog(LOG_ERR, "Starting SYSLOG daemon with pid:%d", (int)getpid());
ctdb_set_process_name("ctdb_syslogd");
close(state->fd[0]);
close(startup_fd[0]);

View File

@ -90,6 +90,7 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
if (child == 0) {
int ret;
ctdb_set_process_name("ctdb_notification");
debug_extra = talloc_asprintf(NULL, "notification-%s:", event);
ret = ctdb_run_notification_script_child(ctdb, event);
if (ret != 0) {

View File

@ -669,6 +669,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
char cc = 0;
close(state->fd[0]);
ctdb_set_process_name("ctdb_recmode");
debug_extra = talloc_asprintf(NULL, "set_recmode:");
/* we should not be able to get the lock on the reclock file,
as it should be held by the recovery master

View File

@ -2165,6 +2165,7 @@ static void getlog_handler(struct ctdb_context *ctdb, uint64_t srvid,
}
if (child == 0) {
ctdb_set_process_name("ctdb_rec_log_collector");
if (switch_from_server_to_client(ctdb, "recoverd-log-collector") != 0) {
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
_exit(1);
@ -3224,6 +3225,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
close(state->fd[0]);
state->fd[0] = -1;
ctdb_set_process_name("ctdb_rec_reclock");
debug_extra = talloc_asprintf(NULL, "recovery-lock:");
if (pread(ctdb->recovery_lock_fd, &cc, 1, 0) == -1) {
DEBUG(DEBUG_CRIT,("failed read from recovery_lock_fd - %s\n", strerror(errno)));
@ -4070,6 +4072,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
/* Clear the log ringbuffer */
ctdb_clear_log(ctdb);
ctdb_set_process_name("ctdb_recovered");
if (switch_from_server_to_client(ctdb, "recoverd") != 0) {
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n"));
exit(1);

View File

@ -4524,6 +4524,7 @@ int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb, struct ctdb_re
close(h->fd[0]);
debug_extra = talloc_asprintf(NULL, "reloadips:");
ctdb_set_process_name("ctdb_reloadips");
if (switch_from_server_to_client(ctdb, "reloadips-child") != 0) {
DEBUG(DEBUG_CRIT,("ERROR: Failed to switch reloadips child into client mode\n"));
res = -1;

View File

@ -182,6 +182,7 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
close(h->fd[0]);
ctdb_set_process_name("ctdb_traverse");
if (switch_from_server_to_client(ctdb_db->ctdb,
"traverse_local-%s:",
ctdb_db->db_name) != 0) {

View File

@ -250,6 +250,7 @@ static struct childwrite_handle *ctdb_childwrite(
char c = 0;
close(result->fd[0]);
ctdb_set_process_name("ctdb_write_persistent");
debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
ret = ctdb_persistent_store(state);
if (ret != 0) {

View File

@ -1627,7 +1627,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
close(child_ctx->fd[0]);
DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
ctdb_set_process_name("ctdb_vacuum");
if (switch_from_server_to_client(ctdb, "vacuum-%s", ctdb_db->db_name) != 0) {
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch vacuum daemon into client mode. Shutting down.\n"));
_exit(1);

View File

@ -407,6 +407,7 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
ctdb_eventscript_call_names[state->call]);
close(state->fd[0]);
set_close_on_exec(state->fd[1]);
ctdb_set_process_name("ctdb_eventscript");
rt = child_run_script(ctdb, state->from_user, state->call, state->options, current);
/* We must be able to write PIPEBUF bytes at least; if this
@ -540,6 +541,7 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_ev
if (pid == 0) {
char *buf;
ctdb_set_process_name("ctdb_debug_hung_script");
if (getenv("CTDB_DEBUG_HUNG_SCRIPT") != NULL) {
debug_hung_script = getenv("CTDB_DEBUG_HUNG_SCRIPT");
}