pgpool2.git / summary / log / commit / refs
commit 4fc6bd81511e5b281152d66b471889fa81469ba2
Author: Muhammad Usama <m.usama@HighGo.ca>
Commit: Muhammad Usama <m.usama@gmail.com>
Date: Thu Jul 02 18:05:30 2020 +0000
Fix for log messages from child processes printing the main process's PID
The issue was caused by my log collector commit. And the reason was: as part of
the log collector implementation, I added a new global variable myProcPid to hold
to the process PID so that we can avoid calling getpid() function every time
during the construction of the log message.
The change was meant to increase the performance but unfortunately I missed
setting the myProcPid variable after fork() at one of the places.
(After forking the pgpool child process).
So to make sure we can avoid such mistakes in the future, I also did a little bit
of refactoring as part of this fix and created a new function that sets all
process-related global variables (process_application_name, myProcPid and
processType) so that we have a single place to add/modify such stuff.
Apart from that, I have made a few changes in functions for setting the
process_application_name and moved them to pool_globasl.c from pgpool_main.c
src/include/pool.h | 12 ++++--
src/main/main.c | 5 ++-
src/main/pgpool_logger.c | 3 +-
src/main/pgpool_main.c | 97 ++----------------------------------------
src/main/pool_globals.c | 84 +++++++++++++++++++++++++++++++++++-
src/pcp_con/pcp_child.c | 10 +----
src/protocol/child.c | 2 -
src/tools/pgenc/Makefile.am | 8 +---
src/tools/pgenc/Makefile.in | 17 +++-----
src/tools/pgmd5/Makefile.am | 8 +---
src/tools/pgmd5/Makefile.in | 12 ++----
src/tools/watchdog/Makefile.am | 5 +--
src/tools/watchdog/Makefile.in | 7 +--
src/watchdog/watchdog.c | 5 +--
src/watchdog/wd_escalation.c | 8 +---
src/watchdog/wd_heartbeat.c | 8 +---
src/watchdog/wd_if.c | 4 +-
src/watchdog/wd_lifecheck.c | 6 +--
src/watchdog/wd_ping.c | 5 +--
19 files changed, 122 insertions(+), 184 deletions(-)
diff --git a/src/include/pool.h b/src/include/pool.h
index 7f395e033..c3ff2ecc3 100644
--- a/src/include/pool.h
+++ b/src/include/pool.h
@@ -540,6 +540,14 @@ extern pid_t mypid; /* parent pid */
extern pid_t myProcPid; /* process pid */
extern ProcessType processType;
extern ProcessState processState;
+extern void set_application_name(ProcessType ptype);
+extern void set_application_name_with_string(char *string);
+extern void set_application_name_with_suffix(ProcessType ptype, int suffix);
+extern char *get_application_name(void);
+extern char *get_application_name_for_procees(ProcessType ptype);
+
+void SetProcessGlobalVaraibles(ProcessType pType);
+
extern volatile SI_ManageInfo *si_manage_info;
extern volatile sig_atomic_t sigusr2_received;
@@ -613,10 +621,6 @@ extern POOL_NODE_STATUS * verify_backend_node_status(POOL_CONNECTION_POOL_SLOT *
extern POOL_NODE_STATUS * pool_get_node_status(void);
extern void pool_set_backend_status_changed_time(int backend_id);
extern int get_next_master_node(void);
-extern void set_application_name(ProcessType ptype);
-extern void set_application_name_with_string(char *string);
-extern void set_application_name_with_suffix(ProcessType ptype, int suffix);
-extern char *get_application_name(void);
diff --git a/src/main/main.c b/src/main/main.c
index 0f79e7e56..c463b0f3e 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -222,7 +222,8 @@ main(int argc, char **argv)
hba_file = make_absolute_path(hba_file_path, base_dir);
mypid = getpid();
- myProcPid = mypid;
+ SetProcessGlobalVaraibles(PT_MAIN);
+
pool_init_config();
@@ -479,7 +480,7 @@ daemonize(void)
#endif
mypid = getpid();
- myProcPid = mypid;
+ SetProcessGlobalVaraibles(PT_MAIN);
write_pid_file();
if (chdir("/"))
ereport(WARNING,
diff --git a/src/main/pgpool_logger.c b/src/main/pgpool_logger.c
index 0e6b56cdb..40d238e59 100644
--- a/src/main/pgpool_logger.c
+++ b/src/main/pgpool_logger.c
@@ -525,8 +525,7 @@ SysLogger_Start(void)
case 0:
on_exit_reset();
- myProcPid = getpid();
- processType = PT_LOGGER;
+ SetProcessGlobalVaraibles(PT_LOGGER);
/* do the work */
SysLoggerMain(0, NULL);
break;
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 86ef9b16b..0fe558b20 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -239,9 +239,6 @@ PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
/* For PostmasterRandom */
gettimeofday(&random_start_time, NULL);
- /* Set the process type variable */
- processType = PT_MAIN;
- set_application_name(processType);
processState = INITIALIZING;
/*
@@ -616,13 +613,11 @@ pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file)
if (pid == 0)
{
on_exit_reset();
+ SetProcessGlobalVaraibles(PT_PCP);
close(pipe_fds[0]);
close(pipe_fds[1]);
- /* Set the process type variable */
- processType = PT_PCP;
- myProcPid = getpid();
/* call PCP child main */
POOL_SETMASK(&UnBlockSig);
health_check_timer_expired = 0;
@@ -666,8 +661,7 @@ fork_a_child(int *fds, int id)
close(pipe_fds[1]);
}
- /* Set the process type variable */
- processType = PT_CHILD;
+ SetProcessGlobalVaraibles(PT_CHILD);
/* call child main */
POOL_SETMASK(&UnBlockSig);
@@ -714,10 +708,7 @@ worker_fork_a_child(ProcessType type, void (*func) (), void *params)
close(pipe_fds[1]);
}
- /* Set the process type variable */
- processType = type;
- myProcPid = getpid();
- set_application_name(type);
+ SetProcessGlobalVaraibles(type);
/* call child main */
POOL_SETMASK(&UnBlockSig);
@@ -3251,8 +3242,7 @@ fork_follow_child(int old_master, int new_primary, int old_primary)
if (pid == 0)
{
on_exit_reset();
- processType = PT_FOLLOWCHILD;
- myProcPid = getpid();
+ SetProcessGlobalVaraibles(PT_FOLLOWCHILD);
ereport(LOG,
(errmsg("start triggering follow command.")));
for (i = 0; i < pool_config->backend_desc->num_backends; i++)
@@ -4156,82 +4146,3 @@ pool_set_backend_status_changed_time(int backend_id)
tval = time(NULL);
BACKEND_INFO(backend_id).status_changed_time = tval;
}
-
-/*
- * Application name
- */
-static char *process_application_name = "main";
-
-/*
- * Fixed application names. ordered by ProcessType.
- */
-char *application_names[] = {"main",
- "child",
- "sr_check_worker",
- "heart_beat_sender",
- "heart_beat_receiver",
- "watchdog",
- "life_check",
- "follow_child",
- "watchdog_utility",
- "pcp_main",
- "pcp_child",
- "health_check"
-};
-
-/*
- * Set application name by ProcessType
- */
-void
-set_application_name(ProcessType ptype)
-{
- if (ptype < 0 || ptype >= PT_LAST_PTYPE)
- {
- ereport(ERROR,
- (errmsg("failed to set application name. process type: %d", ptype)));
- }
-
- process_application_name = application_names[ptype];
-
- return;
-}
-
-/*
- * Set application name with arbitrary string. The storage for the string must
- * be persistent at least in the session.
- */
-void
-set_application_name_with_string(char *string)
-{
- process_application_name = string;
-}
-
-/*
- * Set application name with suffix
- */
-void
-set_application_name_with_suffix(ProcessType ptype, int suffix)
-{
- char *appname_buf;
-
- if (ptype < 0 || ptype >= PT_LAST_PTYPE)
- {
- ereport(ERROR,
- (errmsg("failed to set application name. process type: %d", ptype)));
- }
-
- appname_buf = MemoryContextAlloc(TopMemoryContext, POOLCONFIG_MAXNAMELEN);
- snprintf(appname_buf, POOLCONFIG_MAXNAMELEN, "%s%d", application_names[ptype], suffix);
- process_application_name = appname_buf;
-
- return;
-}
-
-/*
- * Get current application name
- */
-char *
-get_application_name(void)
-{
- return process_application_name;
-}
diff --git a/src/main/pool_globals.c b/src/main/pool_globals.c
index 45a36750a..8f9276a0c 100644
--- a/src/main/pool_globals.c
+++ b/src/main/pool_globals.c
@@ -5,7 +5,7 @@
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2010 PgPool Global Development Group
+ * Copyright (c) 2003-2020 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -20,9 +20,91 @@
*
* Global variables. Should be eventually removed.
*/
+#include <unistd.h> /*For getpid*/
#include "pool.h"
+#include "utils/elog.h"
+
pid_t mypid; /* pgpool parent process id */
pid_t myProcPid; /* process pid */
ProcessType processType;
ProcessState processState;
+
+/*
+ * Application name
+ */
+static char *process_application_name = "main";
+
+/*
+ * Fixed application names. ordered by ProcessType.
+ */
+char *application_names[] = {"main",
+ "child",
+ "sr_check_worker",
+ "heart_beat_sender",
+ "heart_beat_receiver",
+ "watchdog",
+ "life_check",
+ "follow_child",
+ "watchdog_utility",
+ "pcp_main",
+ "pcp_child",
+ "health_check"
+};
+
+char *
+get_application_name_for_procees(ProcessType ptype)
+{
+ if (ptype < 0 || ptype >= PT_LAST_PTYPE)
+ {
+ ereport(ERROR,
+ (errmsg("failed to set application name. process type: %d", ptype)));
+ }
+ return application_names[ptype];
+}
+
+/*
+ * Set application name by ProcessType
+ */
+void
+set_application_name(ProcessType ptype)
+{
+ process_application_name = get_application_name_for_procees(ptype);
+}
+
+/*
+ * Set application name with arbitrary string. The storage for the string must
+ * be persistent at least in the session.
+ */
+void
+set_application_name_with_string(char *string)
+{
+ process_application_name = string;
+}
+
+/*
+ * Set application name with suffix
+ */
+void
+set_application_name_with_suffix(ProcessType ptype, int suffix)
+{
+ static char appname_buf[POOLCONFIG_MAXNAMELEN +1];
+ snprintf(appname_buf, POOLCONFIG_MAXNAMELEN, "%s%d", get_application_name_for_procees(ptype), suffix);
+ set_application_name_with_string(appname_buf);
+}
+
+/*
+ * Get current application name
+ */
+char *
+get_application_name(void)
+{
+ return process_application_name;
+}
+
+void SetProcessGlobalVaraibles(ProcessType pType)
+{
+ processType = pType;
+ myProcPid = getpid();
+ set_application_name(pType);
+}
diff --git a/src/pcp_con/pcp_child.c b/src/pcp_con/pcp_child.c
index d60acc00b..49042d399 100644
--- a/src/pcp_con/pcp_child.c
+++ b/src/pcp_con/pcp_child.c
@@ -108,9 +108,6 @@ pcp_main(int unix_fd, int inet_fd)
sigjmp_buf local_sigjmp_buf;
struct timeval uptime;
- /* set application name */
- set_application_name(PT_PCP);
-
/* Identify myself via ps */
init_ps_display("", "", "", "");
@@ -270,17 +267,12 @@ start_pcp_command_processor_process(int port)
if (pid == 0) /* child */
{
- /* Set the process type variable */
- processType = PT_PCP_WORKER;
-
- /* set application name */
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_PCP_WORKER);
on_exit_reset();
/* Close the listen sockets sockets */
close(pcp_unix_fd);
close(pcp_inet_fd);
- myProcPid = getpid();
/* call PCP child main */
if (pcp_worker_children)
list_free(pcp_worker_children);
diff --git a/src/protocol/child.c b/src/protocol/child.c
index 2ee2678ee..a064a5962 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -149,8 +149,6 @@ do_child(int *fds)
int connections_count = 0; /* used if child_max_connections > 0 */
char psbuf[NI_MAXHOST + 128];
- set_application_name(PT_CHILD);
-
ereport(DEBUG2,
(errmsg("I am Pgpool Child process with pid: %d", getpid())));
diff --git a/src/tools/pgenc/Makefile.am b/src/tools/pgenc/Makefile.am
index b04fb4d9a..643ad51b4 100644
--- a/src/tools/pgenc/Makefile.am
+++ b/src/tools/pgenc/Makefile.am
@@ -7,14 +7,12 @@ nodist_pg_enc_SOURCES = ssl_utils.c \
md5.c \
base64.c \
pool_passwd.c \
- pool_signal.c \
strlcpy.c \
regex_array.c \
pool_config_variables.c \
pool_config.c \
fe_memutils.c \
- pool_path.c \
- pool_globals.c
+ pool_path.c
DEFS = @DEFS@ \
-DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -35,8 +33,6 @@ base64.h: ../../../src/include/utils/base64.h
rm -f $@ && ln -s $< .
ssl_utils.h: ../../../src/include/utils/ssl_utils.h
rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
- rm -f $@ && ln -s $< .
strlcpy.c: ../../../src/utils/strlcpy.c
rm -f $@ && ln -s $< .
regex_array.c: ../../../src/utils/regex_array.c
@@ -47,8 +43,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_pg_enc_SOURCES)
diff --git a/src/tools/pgenc/Makefile.in b/src/tools/pgenc/Makefile.in
index c78dbd04c..44e8505a4 100644
--- a/src/tools/pgenc/Makefile.in
+++ b/src/tools/pgenc/Makefile.in
@@ -101,11 +101,10 @@ PROGRAMS = $(bin_PROGRAMS)
am__dirstamp = $(am__leading_dot)dirstamp
dist_pg_enc_OBJECTS = pg_enc.$(OBJEXT) ../fe_port.$(OBJEXT)
nodist_pg_enc_OBJECTS = ssl_utils.$(OBJEXT) md5.$(OBJEXT) \
- base64.$(OBJEXT) pool_passwd.$(OBJEXT) pool_signal.$(OBJEXT) \
- strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
- pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
- fe_memutils.$(OBJEXT) pool_path.$(OBJEXT) \
- pool_globals.$(OBJEXT)
+ base64.$(OBJEXT) pool_passwd.$(OBJEXT) strlcpy.$(OBJEXT) \
+ regex_array.$(OBJEXT) pool_config_variables.$(OBJEXT) \
+ pool_config.$(OBJEXT) fe_memutils.$(OBJEXT) \
+ pool_path.$(OBJEXT)
pg_enc_OBJECTS = $(dist_pg_enc_OBJECTS) $(nodist_pg_enc_OBJECTS)
pg_enc_LDADD = $(LDADD)
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -319,14 +318,12 @@ nodist_pg_enc_SOURCES = ssl_utils.c \
md5.c \
base64.c \
pool_passwd.c \
- pool_signal.c \
strlcpy.c \
regex_array.c \
pool_config_variables.c \
pool_config.c \
fe_memutils.c \
- pool_path.c \
- pool_globals.c
+ pool_path.c
all: all-am
@@ -665,8 +662,6 @@ base64.h: ../../../src/include/utils/base64.h
rm -f $@ && ln -s $< .
ssl_utils.h: ../../../src/include/utils/ssl_utils.h
rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
- rm -f $@ && ln -s $< .
strlcpy.c: ../../../src/utils/strlcpy.c
rm -f $@ && ln -s $< .
regex_array.c: ../../../src/utils/regex_array.c
@@ -677,8 +672,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_pg_enc_SOURCES)
diff --git a/src/tools/pgmd5/Makefile.am b/src/tools/pgmd5/Makefile.am
index b9881ab88..ec0d9ba26 100644
--- a/src/tools/pgmd5/Makefile.am
+++ b/src/tools/pgmd5/Makefile.am
@@ -5,13 +5,11 @@ dist_pg_md5_SOURCES = pg_md5.c \
../fe_port.c
nodist_pg_md5_SOURCES = md5.c \
pool_passwd.c \
- pool_signal.c \
strlcpy.c \
regex_array.c \
pool_config_variables.c \
pool_config.c \
- fe_memutils.c \
- pool_globals.c
+ fe_memutils.c
DEFS = @DEFS@ \
-DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -22,8 +20,6 @@ md5.h: ../../../src/include/auth/md5.h
rm -f $@ && ln -s $< .
pool_passwd.c: ../../../src/auth/pool_passwd.c
rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
- rm -f $@ && ln -s $< .
strlcpy.c: ../../../src/utils/strlcpy.c
rm -f $@ && ln -s $< .
regex_array.c: ../../../src/utils/regex_array.c
@@ -34,8 +30,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_pg_md5_SOURCES)
diff --git a/src/tools/pgmd5/Makefile.in b/src/tools/pgmd5/Makefile.in
index 226b45f0d..ebd150003 100644
--- a/src/tools/pgmd5/Makefile.in
+++ b/src/tools/pgmd5/Makefile.in
@@ -101,9 +101,9 @@ PROGRAMS = $(bin_PROGRAMS)
am__dirstamp = $(am__leading_dot)dirstamp
dist_pg_md5_OBJECTS = pg_md5.$(OBJEXT) ../fe_port.$(OBJEXT)
nodist_pg_md5_OBJECTS = md5.$(OBJEXT) pool_passwd.$(OBJEXT) \
- pool_signal.$(OBJEXT) strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
+ strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
- fe_memutils.$(OBJEXT) pool_globals.$(OBJEXT)
+ fe_memutils.$(OBJEXT)
pg_md5_OBJECTS = $(dist_pg_md5_OBJECTS) $(nodist_pg_md5_OBJECTS)
pg_md5_LDADD = $(LDADD)
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -315,13 +315,11 @@ dist_pg_md5_SOURCES = pg_md5.c \
nodist_pg_md5_SOURCES = md5.c \
pool_passwd.c \
- pool_signal.c \
strlcpy.c \
regex_array.c \
pool_config_variables.c \
pool_config.c \
- fe_memutils.c \
- pool_globals.c
+ fe_memutils.c
all: all-am
@@ -650,8 +648,6 @@ md5.h: ../../../src/include/auth/md5.h
rm -f $@ && ln -s $< .
pool_passwd.c: ../../../src/auth/pool_passwd.c
rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
- rm -f $@ && ln -s $< .
strlcpy.c: ../../../src/utils/strlcpy.c
rm -f $@ && ln -s $< .
regex_array.c: ../../../src/utils/regex_array.c
@@ -662,8 +658,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_pg_md5_SOURCES)
diff --git a/src/tools/watchdog/Makefile.am b/src/tools/watchdog/Makefile.am
index e3ab79b3c..e54df8584 100644
--- a/src/tools/watchdog/Makefile.am
+++ b/src/tools/watchdog/Makefile.am
@@ -21,8 +21,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
socket_stream.c \
regex_array.c \
psprintf.c \
- md5.c \
- pool_globals.c
+ md5.c
DEFS = @DEFS@ \
-DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -67,8 +66,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_wd_cli_SOURCES) $(dist_bin_SCRIPTS)
diff --git a/src/tools/watchdog/Makefile.in b/src/tools/watchdog/Makefile.in
index 6a1f66e06..910635256 100644
--- a/src/tools/watchdog/Makefile.in
+++ b/src/tools/watchdog/Makefile.in
@@ -106,7 +106,7 @@ nodist_wd_cli_OBJECTS = ssl_utils.$(OBJEXT) wd_ipc_conn.$(OBJEXT) \
pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
fe_memutils.$(OBJEXT) stringinfo.$(OBJEXT) strlcpy.$(OBJEXT) \
socket_stream.$(OBJEXT) regex_array.$(OBJEXT) \
- psprintf.$(OBJEXT) md5.$(OBJEXT) pool_globals.$(OBJEXT)
+ psprintf.$(OBJEXT) md5.$(OBJEXT)
wd_cli_OBJECTS = $(dist_wd_cli_OBJECTS) $(nodist_wd_cli_OBJECTS)
wd_cli_LDADD = $(LDADD)
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -360,8 +360,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
socket_stream.c \
regex_array.c \
psprintf.c \
- md5.c \
- pool_globals.c
+ md5.c
all: all-am
@@ -760,8 +759,6 @@ pool_config.c: ../../../src/config/pool_config.c
rm -f $@ && ln -s $< .
fe_memutils.c: ../../../src/tools/fe_memutils.c
rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
- rm -f $@ && ln -s $< .
clean-local:
-rm -f $(nodist_wd_cli_SOURCES) $(dist_bin_SCRIPTS)
diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
index ae433c8ed..841a349d5 100644
--- a/src/watchdog/watchdog.c
+++ b/src/watchdog/watchdog.c
@@ -1099,10 +1099,7 @@ fork_watchdog_child(void)
{
on_exit_reset();
- /* Set the process type variable */
- processType = PT_WATCHDOG;
- myProcPid = getpid();
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_WATCHDOG);
/* call watchdog child main */
POOL_SETMASK(&UnBlockSig);
diff --git a/src/watchdog/wd_escalation.c b/src/watchdog/wd_escalation.c
index 7e8760432..686ac0e89 100644
--- a/src/watchdog/wd_escalation.c
+++ b/src/watchdog/wd_escalation.c
@@ -73,9 +73,7 @@ fork_escalation_process(void)
return pid;
}
on_exit_reset();
- processType = PT_WATCHDOG_UTILITY;
- myProcPid = getpid();
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
POOL_SETMASK(&UnBlockSig);
@@ -163,9 +161,7 @@ fork_plunging_process(void)
return pid;
}
on_exit_reset();
- myProcPid = getpid();
- processType = PT_WATCHDOG_UTILITY;
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
POOL_SETMASK(&UnBlockSig);
diff --git a/src/watchdog/wd_heartbeat.c b/src/watchdog/wd_heartbeat.c
index a6ed950cd..88a5914d6 100644
--- a/src/watchdog/wd_heartbeat.c
+++ b/src/watchdog/wd_heartbeat.c
@@ -364,9 +364,7 @@ wd_hb_receiver(int fork_wait_time, WdHbIf * hb_if)
}
on_exit_reset();
- processType = PT_HB_RECEIVER;
- myProcPid = getpid();
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_HB_RECEIVER);
if (fork_wait_time > 0)
{
@@ -499,9 +497,7 @@ wd_hb_sender(int fork_wait_time, WdHbIf * hb_if)
}
on_exit_reset();
- myProcPid = getpid();
- processType = PT_HB_SENDER;
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_HB_SENDER);
if (fork_wait_time > 0)
{
diff --git a/src/watchdog/wd_if.c b/src/watchdog/wd_if.c
index 0c68a08c8..19ef6f4cd 100644
--- a/src/watchdog/wd_if.c
+++ b/src/watchdog/wd_if.c
@@ -311,9 +311,7 @@ exec_if_cmd(char *path, char *command)
if (pid == 0)
{
on_exit_reset();
- processType = PT_WATCHDOG_UTILITY;
- set_application_name(processType);
- myProcPid = getpid();
+ SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
close(STDOUT_FILENO);
dup2(pfd[1], STDOUT_FILENO);
close(pfd[0]);
diff --git a/src/watchdog/wd_lifecheck.c b/src/watchdog/wd_lifecheck.c
index 211ca9c2f..71f4374d4 100644
--- a/src/watchdog/wd_lifecheck.c
+++ b/src/watchdog/wd_lifecheck.c
@@ -356,11 +356,7 @@ fork_lifecheck_child(void)
if (pid == 0)
{
on_exit_reset();
-
- /* Set the process type variable */
- processType = PT_LIFECHECK;
- myProcPid = getpid();
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_LIFECHECK);
/* call lifecheck child main */
POOL_SETMASK(&UnBlockSig);
diff --git a/src/watchdog/wd_ping.c b/src/watchdog/wd_ping.c
index 760166b9c..1eed46130 100644
--- a/src/watchdog/wd_ping.c
+++ b/src/watchdog/wd_ping.c
@@ -134,9 +134,8 @@ wd_issue_ping_command(char *hostname, int *outfd)
{
/* CHILD */
on_exit_reset();
- processType = PT_WATCHDOG_UTILITY;
- myProcPid = getpid();
- set_application_name(processType);
+ SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
+
close(STDOUT_FILENO);
dup2(pfd[1], STDOUT_FILENO);
close(pfd[0]);
[parent: 90a2178c1d2f]