Fix problem that syslog_facility don't change by reload
authorTakuma Hoshiai <hoshiai@sraoss.co.jp>
Tue, 8 Oct 2019 04:10:32 +0000 (13:10 +0900)
committerTakuma Hoshiai <hoshiai@sraoss.co.jp>
Tue, 8 Oct 2019 04:10:32 +0000 (13:10 +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/main/main.c
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 fbcacb2b211f60bf09dc35539e34ee0a0ec44bf3..72bcf77623129eca238b098ce060543fadb895c6 100644 (file)
@@ -248,7 +248,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)
 
 dnl Checks for pg_config command.
 AC_CHECK_PROGS(PGCONFIG, pg_config)
index 065c7e567767bdd2e05990f05f47e0b1b664e724..0057d85622174cfc842c733ab5d2fda35357b144 100644 (file)
@@ -491,7 +491,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 5a022b97737302b41e8189d8cccec3ebfe034b56..0dd6c1c2bf473546d3b5935ce5bd3c32071326e4 100644 (file)
@@ -299,7 +299,7 @@ int main(int argc, char **argv)
        else
                daemonize();
        
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
     set_syslog_parameters(pool_config->syslog_ident ? pool_config->syslog_ident : "pgpool",
                           pool_config->syslog_facility);
 #endif
index 36d29d5da9560a31b4967f76e04068de6a2c6d7b..332e60fc12f98c9a85ce65f401d1182056cbcff4 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>
@@ -123,7 +123,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
@@ -1427,7 +1427,7 @@ GetErrorContextStack(void)
 }
 
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
 
 /*
  * Set or update the parameters for syslog logging
@@ -1562,7 +1562,7 @@ write_syslog(int level, const char *line)
                syslog(level, "[%lu] %s", seq, line);
        }
 }
-#endif   /* HAVE_VSYSLOG */
+#endif   /* HAVE_SYSLOG */
 
 #ifdef WIN32
 /*
@@ -2133,7 +2133,7 @@ send_message_to_server_log(ErrorData *edata)
                }
        }
 
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
        /* Write to syslog, if enabled */
     if (pool_config->logsyslog == 1)
     {
@@ -2171,7 +2171,7 @@ send_message_to_server_log(ErrorData *edata)
                if (pool_config->logsyslog == 1)
                        write_syslog(syslog_level, buf.data);
        }
-#endif   /* HAVE_VSYSLOG */
+#endif   /* HAVE_SYSLOG */
 
     write_console(buf.data, buf.len);
        pfree(buf.data);
diff --git a/src/watchdog/test/stab.c b/src/watchdog/test/stab.c
deleted file mode 100644 (file)
index 1fd7241..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;
-#ifdef HAVE_ASPRINTF
-       char            *fmt2;
-    int         len;
-#endif
-
-#ifdef HAVE_SIGPROCMASK
-       sigset_t oldmask;
-#else
-       int     oldmask;
-#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());
-       else
-         fprintf(stderr, "ERROR: pid %d: ", (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 56440be..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 b9e69e8..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 e162828..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 0740a11..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 0b90178..0000000
+++ /dev/null
@@ -1,20 +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;
-}