Fix problem that syslog_facility don't change by reload
authorTakuma Hoshiai <hoshiai@sraoss.co.jp>
Tue, 8 Oct 2019 04:04:46 +0000 (13:04 +0900)
committerTakuma Hoshiai <hoshiai@sraoss.co.jp>
Tue, 8 Oct 2019 04:04:46 +0000 (13:04 +0900)
The cause is macro definition mistake. This fix unify macro definition, and delete old test code to use vsyslog().
Reported in bug 548.

configure.ac
src/include/utils/elog.h
src/utils/error/elog.c
src/watchdog/test/stab.c [deleted file]
src/watchdog/test/test.c [deleted file]
src/watchdog/test/wd_child_t.c [deleted file]
src/watchdog/test/wd_lifecheck_t.c [deleted file]
src/watchdog/test/wd_packet_t.c [deleted file]
src/watchdog/test/wd_ping_t.c [deleted file]

index d14638830922aeb4b68a636e3a2314350f62c4fe..7745116530c6bf99bcca10b54990f4254af10b8a 100644 (file)
@@ -266,7 +266,7 @@ AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
 AC_FUNC_WAIT3
 AC_FUNC_ACCEPT_ARGTYPES
-AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf vasprintf gai_strerror hstrerror pstat setproctitle vsyslog)
+AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf vasprintf gai_strerror hstrerror pstat setproctitle syslog)
 
 PGAC_C_TYPES_COMPATIBLE
 
index 4acec995f8fe77e858dcb9ece15cc68df3508aa5..31d8038abfc1d9070db9810555e0eb60a2b74d83 100644 (file)
@@ -502,7 +502,7 @@ typedef enum
 
 extern bool in_error_recursion_trouble(void);
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
 extern void set_syslog_parameters(const char *ident, int facility);
 #endif
 
index 74928e329feefa6958bdb38351f35fb34859790a..89d3a04b582ff4d9617caef2b253cb1f7078dcfe 100644 (file)
@@ -62,7 +62,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <ctype.h>
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
 #include <syslog.h>
 #endif
 #include <string.h>
@@ -126,7 +126,7 @@ extern bool redirection_done;
  */
 emit_log_hook_type emit_log_hook = NULL;
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
 
 /*
  * Max string length to send to syslog().  Note that this doesn't count the
@@ -1442,7 +1442,7 @@ GetErrorContextStack(void)
 }
 
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
 
 /*
  * Set or update the parameters for syslog logging
@@ -1575,7 +1575,7 @@ write_syslog(int level, const char *line)
                syslog(level, "[%lu] %s", seq, line);
        }
 }
-#endif                                                 /* HAVE_VSYSLOG */
+#endif                                                 /* HAVE_SYSLOG */
 
 #ifdef WIN32
 /*
@@ -2179,7 +2179,7 @@ send_message_to_server_log(ErrorData *edata)
                }
        }
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
        /* Write to syslog, if enabled */
        if (pool_config->log_destination & LOG_DESTINATION_SYSLOG)
        {
@@ -2217,7 +2217,7 @@ send_message_to_server_log(ErrorData *edata)
                }
                write_syslog(syslog_level, buf.data);
        }
-#endif                                                 /* HAVE_VSYSLOG */
+#endif                                                 /* HAVE_SYSLOG */
 
        if (pool_config->log_destination & LOG_DESTINATION_STDERR)
        {
diff --git a/src/watchdog/test/stab.c b/src/watchdog/test/stab.c
deleted file mode 100644 (file)
index da66a5b..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <wait.h>
-
-#include "pool.h"
-#include "pool_config.h"
-
-#define MAXSTRFTIME 128
-
-int                    debug = 0;
-
-
-static char *nowsec(void);
-static void child_wait(int signo);
-
-void
-pool_error(const char *fmt,...)
-{
-       va_list         ap;
-       pool_sigset_t oldmask;
-#ifdef HAVE_ASPRINTF
-       char       *fmt2;
-       int                     len;
-#endif
-       /* Write error message to syslog */
-       if (pool_config->logsyslog == 1)
-       {
-               va_start(ap, fmt);
-               vsyslog(pool_config->syslog_facility | LOG_ERR, fmt, ap);
-               va_end(ap);
-               return;
-       }
-
-       POOL_SETMASK2(&BlockSig, &oldmask);
-
-       /*
-        * TODO if (pool_config->print_timestamp)
-        */
-#ifdef HAVE_ASPRINTF
-       len = asprintf(&fmt2, "%s ERROR: pid %d: %s\n", nowsec(), (int) getpid(), fmt);
-
-       if (len >= 0 && fmt2)
-       {
-               va_start(ap, fmt);
-               vfprintf(stderr, fmt2, ap);
-               va_end(ap);
-               fflush(stderr);
-               free(fmt2);
-       }
-#else
-       fprintf(stderr, "%s ERROR: pid %d: ", nowsec(), (int) getpid());
-
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       fprintf(stderr, "\n");
-#endif
-
-       POOL_SETMASK(&oldmask);
-}
-
-static char *
-nowsec(void)
-{
-       static char strbuf[MAXSTRFTIME];
-       time_t          now = time(NULL);
-
-       strftime(strbuf, MAXSTRFTIME, "%Y-%m-%d %H:%M:%S", localtime(&now));
-       return strbuf;
-}
-
-size_t
-strlcpy(char *dst, const char *src, size_t siz)
-{
-       char       *d = dst;
-       const char *s = src;
-       size_t          n = siz;
-
-       /* Copy as many bytes as will fit */
-       if (n != 0)
-       {
-               while (--n != 0)
-               {
-                       if ((*d++ = *s++) == '\0')
-                               break;
-               }
-       }
-
-       /* Not enough room in dst, add NUL and traverse rest of src */
-       if (n == 0)
-       {
-               if (siz != 0)
-                       *d = '\0';                      /* NUL-terminate dst */
-               while (*s++)
-                       ;
-       }
-
-       return (s - src - 1);           /* count does not include NUL */
-}
-
-static void
-child_wait(int signo)
-{
-       pid_t           pid = 0;
-
-       do
-       {
-               int                     ret;
-
-               pid = waitpid(-1, &ret, WNOHANG);
-       } while (pid > 0);
-}
-
-void
-wd_exit(int exit_signo)
-{
-       sigset_t        mask;
-
-       sigemptyset(&mask);
-       sigaddset(&mask, SIGTERM);
-       sigaddset(&mask, SIGINT);
-       sigaddset(&mask, SIGQUIT);
-       sigaddset(&mask, SIGCHLD);
-       sigprocmask(SIG_BLOCK, &mask, NULL);
-
-       wd_notice_server_down();
-
-       pool_shmem_exit(1);
-
-       kill(0, exit_signo);
-
-       child_wait(0);
-
-       exit(0);
-}
-
-int
-pool_memset_system_db_info(SystemDBInfo * info)
-{
-       return 0;
-}
-
-int
-pool_query_cache_table_exists(void)
-{
-       return 0;
-}
diff --git a/src/watchdog/test/test.c b/src/watchdog/test/test.c
deleted file mode 100644 (file)
index 26b7ed3..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "pool.h"
-#include "pool_config.h"
-#include "watchdog.h"
-#include "wd_ext.h"
-
-pid_t          mypid;
-
-static void wdlist_dump(void);
-extern void wd_exit(int exit_signo);
-
-int
-main(int argc, char *argv[])
-{
-       int                     rtn;
-
-       signal(SIGCHLD, SIG_DFL);
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, wd_exit);
-       signal(SIGQUIT, wd_exit);
-       signal(SIGTERM, wd_exit);
-       signal(SIGPIPE, SIG_IGN);
-
-       mypid = getpid();
-       rtn = pool_init_config();
-
-       pool_config->recovery_user = "mitani";
-       pool_config->trusted_servers = "paris";
-       pool_config->delegate_IP = "192.168.100.99";
-       pool_config->pgpool2_hostname = "vm1";
-       pool_config->port = 5432;
-       pool_config->wd_port = 9999;
-       pool_config->other_wd->num_wd = 2;
-       strcpy(pool_config->other_wd->wd_info[0].hostname, "vm2");
-       pool_config->other_wd->wd_info[0].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[0].wd_port = 9999;
-       pool_config->other_wd->wd_info[0].status = WD_INIT;
-       strcpy(pool_config->other_wd->wd_info[1].hostname, "paris");
-       pool_config->other_wd->wd_info[1].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[1].wd_port = 9999;
-       pool_config->other_wd->wd_info[1].status = WD_INIT;
-       pool_config->ping_path = "/bin";
-       pool_config->ifconfig_path = "/sbin";
-       pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
-       pool_config->if_down_cmd = "ifconfig eth0:0 down";
-       pool_config->wd_interval = 3;
-       pool_config->wd_life_point = 1;
-
-       wd_main(3);
-
-       for (;;)
-       {
-               wdlist_dump();
-               sleep(5);
-       }
-       wd_exit(15);
-
-}
-
-
-static void
-wdlist_dump(void)
-{
-       int                     i;
-       WdInfo     *p = WD_List;
-
-       i = 0;
-       while (p->status != WD_END)
-       {
-               printf("%d:s[%d] ts[%d] tu[%d] h[%s] pp[%d] wp[%d]\n",
-                          i, p->status,
-                          p->tv.tv_sec, p->tv.tv_usec,
-                          p->hostname,
-                          p->pgpool_port,
-                          p->wd_port);
-               p++;
-               i++;
-       }
-}
diff --git a/src/watchdog/test/wd_child_t.c b/src/watchdog/test/wd_child_t.c
deleted file mode 100644 (file)
index a469ca7..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "pool.h"
-#include "pool_config.h"
-#include "watchdog.h"
-#include "wd_ext.h"
-
-pid_t          mypid;
-WdInfo    *WD_List = NULL;             /* watchdog server list */
-
-static void wdlist_dump(void);
-extern void wd_exit(int exit_signo);
-
-int
-main(int argc, char *argv[])
-{
-       int                     rtn;
-
-       signal(SIGCHLD, SIG_DFL);
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, wd_exit);
-       signal(SIGQUIT, wd_exit);
-       signal(SIGTERM, wd_exit);
-       signal(SIGPIPE, SIG_IGN);
-
-       mypid = getpid();
-       rtn = pool_init_config();
-
-       pool_config->recovery_user = "mitani";
-       pool_config->trusted_servers = "paris";
-       pool_config->delegate_IP = "192.168.100.99";
-       pool_config->pgpool2_hostname = "vm1";
-       pool_config->port = 5432;
-       pool_config->wd_port = 9999;
-       pool_config->other_wd->num_wd = 2;
-       strcpy(pool_config->other_wd->wd_info[0].hostname, "vm2");
-       pool_config->other_wd->wd_info[0].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[0].wd_port = 9999;
-       pool_config->other_wd->wd_info[0].status = WD_INIT;
-       strcpy(pool_config->other_wd->wd_info[1].hostname, "paris");
-       pool_config->other_wd->wd_info[1].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[1].wd_port = 9999;
-       pool_config->other_wd->wd_info[1].status = WD_INIT;
-       pool_config->ping_path = "/bin";
-       pool_config->ifconfig_path = "/sbin";
-       pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
-       pool_config->if_down_cmd = "ifconfig eth0:0 down";
-       pool_config->wd_interval = 3;
-       pool_config->wd_life_point = 1;
-
-       wd_init();
-
-       wd_child(1);
-
-       for (;;)
-       {
-               wdlist_dump();
-               sleep(5);
-       }
-
-}
-
-
-static void
-wdlist_dump(void)
-{
-       int                     i;
-       WdInfo     *p = WD_List;
-
-       i = 0;
-       while (p->status != WD_END)
-       {
-               printf("%d:s[%d] ts[%d] tu[%d] h[%s] pp[%d] wp[%d]\n",
-                          i, p->status,
-                          p->tv.tv_sec, p->tv.tv_usec,
-                          p->hostname,
-                          p->pgpool_port,
-                          p->wd_port);
-               p++;
-               i++;
-       }
-}
diff --git a/src/watchdog/test/wd_lifecheck_t.c b/src/watchdog/test/wd_lifecheck_t.c
deleted file mode 100644 (file)
index 4fd5ffd..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "pool.h"
-#include "pool_config.h"
-#include "watchdog.h"
-#include "wd_ext.h"
-
-pid_t          mypid;
-WdInfo    *WD_List = NULL;             /* watchdog server list */
-
-static void wdlist_dump(void);
-extern void wd_exit(int exit_signo);
-
-int
-main(int argc, char *argv[])
-{
-       int                     rtn;
-
-       signal(SIGCHLD, SIG_DFL);
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, wd_exit);
-       signal(SIGQUIT, wd_exit);
-       signal(SIGTERM, wd_exit);
-       signal(SIGPIPE, SIG_IGN);
-
-       mypid = getpid();
-       rtn = pool_init_config();
-
-       pool_config->recovery_user = "mitani";
-       pool_config->trusted_servers = "paris";
-       pool_config->delegate_IP = "192.168.100.99";
-       pool_config->pgpool2_hostname = "vm1";
-       pool_config->port = 5432;
-       pool_config->wd_port = 9999;
-       pool_config->other_wd->num_wd = 2;
-       strcpy(pool_config->other_wd->wd_info[0].hostname, "vm2");
-       pool_config->other_wd->wd_info[0].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[0].wd_port = 9999;
-       pool_config->other_wd->wd_info[0].status = WD_INIT;
-       strcpy(pool_config->other_wd->wd_info[1].hostname, "paris");
-       pool_config->other_wd->wd_info[1].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[1].wd_port = 9999;
-       pool_config->other_wd->wd_info[1].status = WD_INIT;
-       pool_config->ping_path = "/bin";
-       pool_config->ifconfig_path = "/sbin";
-       pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
-       pool_config->if_down_cmd = "ifconfig eth0:0 down";
-       pool_config->wd_interval = 3;
-       pool_config->wd_life_point = 1;
-
-       wd_init();
-
-       for (;;)
-       {
-               wdlist_dump();
-               wd_lifecheck();
-               sleep(pool_config->wd_interval);
-       }
-       wd_exit(15);
-
-}
-
-
-static void
-wdlist_dump(void)
-{
-       int                     i;
-       WdInfo     *p = WD_List;
-
-       i = 0;
-       while (p->status != WD_END)
-       {
-               printf("%d:s[%d] ts[%d] tu[%d] h[%s] pp[%d] wp[%d]\n",
-                          i, p->status,
-                          p->tv.tv_sec, p->tv.tv_usec,
-                          p->hostname,
-                          p->pgpool_port,
-                          p->wd_port);
-               p++;
-               i++;
-       }
-}
diff --git a/src/watchdog/test/wd_packet_t.c b/src/watchdog/test/wd_packet_t.c
deleted file mode 100644 (file)
index 7b6b909..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "pool.h"
-#include "pool_config.h"
-#include "watchdog.h"
-#include "wd_ext.h"
-
-pid_t          mypid;
-WdInfo    *WD_List = NULL;             /* watchdog server list */
-
-static void wdlist_dump(void);
-extern void wd_exit(int exit_signo);
-
-int
-main(int argc, char *argv[])
-{
-       int                     rtn;
-
-       signal(SIGCHLD, SIG_DFL);
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, wd_exit);
-       signal(SIGQUIT, wd_exit);
-       signal(SIGTERM, wd_exit);
-       signal(SIGPIPE, SIG_IGN);
-
-       mypid = getpid();
-       rtn = pool_init_config();
-
-       pool_config->recovery_user = "mitani";
-       pool_config->trusted_servers = "paris";
-       pool_config->delegate_IP = "192.168.100.99";
-       pool_config->pgpool2_hostname = "vm1";
-       pool_config->port = 5432;
-       pool_config->wd_port = 9999;
-       pool_config->other_wd->num_wd = 2;
-       strcpy(pool_config->other_wd->wd_info[0].hostname, "vm2");
-       pool_config->other_wd->wd_info[0].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[0].wd_port = 9999;
-       pool_config->other_wd->wd_info[0].status = WD_INIT;
-       strcpy(pool_config->other_wd->wd_info[1].hostname, "paris");
-       pool_config->other_wd->wd_info[1].pgpool_port = 5432;
-       pool_config->other_wd->wd_info[1].wd_port = 9999;
-       pool_config->other_wd->wd_info[1].status = WD_INIT;
-       pool_config->ping_path = "/bin";
-       pool_config->ifconfig_path = "/sbin";
-       pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
-       pool_config->if_down_cmd = "ifconfig eth0:0 down";
-       pool_config->wd_interval = 3;
-       pool_config->wd_life_point = 1;
-
-       wd_init();
-
-       for (;;)
-       {
-               wdlist_dump();
-               sleep(5);
-               wd_lifecheck();
-       }
-       wd_exit(15);
-
-}
-
-
-static void
-wdlist_dump(void)
-{
-       int                     i;
-       WdInfo     *p = WD_List;
-
-       i = 0;
-       while (p->status != WD_END)
-       {
-               printf("%d:s[%d] ts[%d] tu[%d] h[%s] pp[%d] wp[%d]\n",
-                          i, p->status,
-                          p->tv.tv_sec, p->tv.tv_usec,
-                          p->hostname,
-                          p->pgpool_port,
-                          p->wd_port);
-               p++;
-               i++;
-       }
-}
diff --git a/src/watchdog/test/wd_ping_t.c b/src/watchdog/test/wd_ping_t.c
deleted file mode 100644 (file)
index 366a272..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-#include "watchdog.h"
-
-extern int     wd_is_upper_ok(char *server_list);
-
-int
-main(int argc, char *argv[])
-{
-       int                     rtn;
-
-       rtn = wd_is_upper_ok(argv[1]);
-       if (rtn == WD_OK)
-       {
-               printf("%s is ok", argv[1]);
-       }
-       else
-       {
-               printf("%s is ng", argv[1]);
-       }
-       return 0;
-}