[PATCHES] ctdb: Use Use prctl_set_comment from lib/util
Christof Schmitt
cs at samba.org
Wed Nov 18 00:28:42 UTC 2015
From 1d6c3ac40846e9b8ab7e34c63c7c9c96698ab13c Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 23 Sep 2015 16:02:27 -0700
Subject: [PATCH 1/3] lib: Move util_process from util to util-core
Make the common prctl_set_comment function available to both ctdb
builds.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
lib/util/wscript_build | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 81578a9..226b15e 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -64,7 +64,7 @@ bld.SAMBA_LIBRARY('talloc_report',
bld.SAMBA_SUBSYSTEM('samba-util-core',
source='''xfile.c data_blob.c util_file.c time.c
signal.c util.c idtree.c fault.c
- substitute.c''',
+ substitute.c util_process.c''',
deps='''time-basic samba-debug socket-blocking talloc
tevent execinfo pthread''',
local_include=False)
@@ -102,7 +102,7 @@ if not bld.env.SAMBA_UTIL_CORE_ONLY:
util_strlist.c util_paths.c idtree_random.c base64.c
util_str.c util_str_common.c ms_fnmatch.c
server_id.c dprintf.c bitmap.c pidfile.c
- tevent_debug.c util_process.c memcache.c''',
+ tevent_debug.c memcache.c''',
deps='samba-util-core DYNCONFIG close-low-fd tini tiniparser genrand',
public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd systemd-daemon',
--
1.7.1
From 519e563bdba3e3fb7a9f385d54101aac96c1434c Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 23 Sep 2015 16:10:59 -0700
Subject: [PATCH 2/3] ctdb: Use prctl_set_comment from lib/util
Signed-off-by: Christof Schmitt <cs at samba.org>
---
ctdb/server/ctdb_call.c | 3 ++-
ctdb/server/ctdb_monitor.c | 3 ++-
ctdb/server/ctdb_recover.c | 3 ++-
ctdb/server/ctdb_recoverd.c | 3 ++-
ctdb/server/ctdb_takeover.c | 3 ++-
ctdb/server/ctdb_traverse.c | 3 ++-
ctdb/server/ctdb_update_record.c | 3 ++-
ctdb/server/ctdb_vacuum.c | 3 ++-
8 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 6d05af8..db9fb6a 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -1887,7 +1888,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");
+ prctl_set_comment("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;
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 4f998d3..d8eda2a 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -28,6 +28,7 @@
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
@@ -104,7 +105,7 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
if (child == 0) {
int ret;
- ctdb_set_process_name("ctdb_notification");
+ prctl_set_comment("ctdb_notification");
debug_extra = talloc_asprintf(NULL, "notification-%s:", event);
ret = ctdb_run_notification_script_child(ctdb, event);
if (ret != 0) {
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index bf045c1..7b34d7e 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -31,6 +31,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -633,7 +634,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
char cc = 0;
close(state->fd[0]);
- ctdb_set_process_name("ctdb_recmode");
+ prctl_set_comment("ctdb_recmode");
debug_extra = talloc_asprintf(NULL, "set_recmode:");
/* Daemon should not be able to get the recover lock,
* as it should be held by the recovery master */
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 3f0cffc..c9f19fa 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -32,6 +32,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -4074,7 +4075,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
srandom(getpid() ^ time(NULL));
- ctdb_set_process_name("ctdb_recovered");
+ prctl_set_comment("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);
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 6844246..c9179d3 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -4518,7 +4519,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");
+ prctl_set_comment("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;
diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c
index 3dea3fa..73c3a06 100644
--- a/ctdb/server/ctdb_traverse.c
+++ b/ctdb/server/ctdb_traverse.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -217,7 +218,7 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
close(h->fd[0]);
- ctdb_set_process_name("ctdb_traverse");
+ prctl_set_comment("ctdb_traverse");
if (switch_from_server_to_client(ctdb, "traverse_local-%s:",
ctdb_db->db_name) != 0) {
DEBUG(DEBUG_CRIT, ("Failed to switch traverse child into client mode\n"));
diff --git a/ctdb/server/ctdb_update_record.c b/ctdb/server/ctdb_update_record.c
index 143520a..bc9c6fe 100644
--- a/ctdb/server/ctdb_update_record.c
+++ b/ctdb/server/ctdb_update_record.c
@@ -28,6 +28,7 @@
#include "lib/tdb_wrap/tdb_wrap.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -265,7 +266,7 @@ static struct childwrite_handle *ctdb_childwrite(
char c = 0;
close(result->fd[0]);
- ctdb_set_process_name("ctdb_write_persistent");
+ prctl_set_comment("ctdb_write_persistent");
debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
ret = ctdb_persistent_store(state);
if (ret != 0) {
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index a81bd54..54dfe99 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -31,6 +31,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -1507,7 +1508,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
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");
+ prctl_set_comment("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);
--
1.7.1
From 0b6fa6fac48d0e453edc336e333e0c0eb6ec3379 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 23 Sep 2015 16:11:51 -0700
Subject: [PATCH 3/3] ctdb: Remove unused ctdb_set_process_name
Signed-off-by: Christof Schmitt <cs at samba.org>
---
ctdb/common/system.h | 1 -
ctdb/common/system_aix.c | 6 ------
ctdb/common/system_freebsd.c | 6 ------
ctdb/common/system_gnu.c | 6 ------
ctdb/common/system_kfreebsd.c | 6 ------
ctdb/common/system_linux.c | 12 ------------
6 files changed, 0 insertions(+), 37 deletions(-)
diff --git a/ctdb/common/system.h b/ctdb/common/system.h
index 8df87cd..ba11d20 100644
--- a/ctdb/common/system.h
+++ b/ctdb/common/system.h
@@ -39,7 +39,6 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
uint32_t *ack_seq, uint32_t *seq);
bool ctdb_sys_check_iface_exists(const char *iface);
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
-int ctdb_set_process_name(const char *name);
/* From system_util.c */
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 4c13106..a380f1c 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -379,9 +379,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
}
return ret;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME AIX: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 97ac06c..21a300b 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -375,9 +375,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME FreeBSD: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME FreeBSD: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index 84c5dd6..aeed56c 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -368,9 +368,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME GNU/Hurd: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME GNU/Hurd: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index bd01410..b241aa8 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -368,9 +368,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME kFreeBSD: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME kFreeBSD: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index e7d9329..23c83d4 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -603,15 +603,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
}
return ret;
}
-
-/*
- * Set process name
- */
-int ctdb_set_process_name(const char *name)
-{
- char procname[16];
-
- strncpy(procname, name, 15);
- procname[15] = '\0';
- return prctl(PR_SET_NAME, (unsigned long)procname, 0, 0, 0);
-}
--
1.7.1
More information about the samba-technical
mailing list