The cause is macro definition mistake. This fix unify macro definition, and delete old test code to use vsyslog().
Reported in bug 548.
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)
extern bool in_error_recursion_trouble(void);
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
extern void set_syslog_parameters(const char *ident, int facility);
#endif
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
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
#include <syslog.h>
#endif
#include <string.h>
*/
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
}
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
/*
* Set or update the parameters for syslog logging
syslog(level, "[%lu] %s", seq, line);
}
}
-#endif /* HAVE_VSYSLOG */
+#endif /* HAVE_SYSLOG */
#ifdef WIN32
/*
}
}
-#ifdef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
/* Write to syslog, if enabled */
if (pool_config->logsyslog == 1)
{
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);
+++ /dev/null
-#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;
-}
-
+++ /dev/null
-#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++;
- }
-}
+++ /dev/null
-#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++;
- }
-}
+++ /dev/null
-#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++;
- }
-}
+++ /dev/null
-#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++;
- }
-}
+++ /dev/null
-#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;
-}