pgpool2.git / summary / log / commit / refs
commit 13a76c036359c535ace01ed6325b5987f8eb4294
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Wed Oct 19 00:11:11 2011 +0000
More fix to be compiled on AIX and other platforms
which does not have vasprintf().
config.h.in | 3 +++
configure | 2 +-
configure.in | 2 +-
pool_error.c | 14 ++++++++++++++
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/config.h.in b/config.h.in
index 4c2249b59..b0a50db22 100644
--- a/config.h.in
+++ b/config.h.in
@@ -230,6 +230,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
diff --git a/configure b/configure
index 9ebfc424c..aa0e17234 100755
--- a/configure
+++ b/configure
@@ -12961,7 +12961,7 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-for ac_func in setsid select socket sigprocmask strdup strerror strftime strtok asprintf gai_strerror hstrerror pstat setproctitle vsyslog
+for ac_func in setsid select socket sigprocmask strdup strerror strftime strtok asprintf vasprintf gai_strerror hstrerror pstat setproctitle vsyslog
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.in b/configure.in
index 728f91b6d..a1f124557 100644
--- a/configure.in
+++ b/configure.in
@@ -229,7 +229,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 gai_strerror hstrerror pstat setproctitle vsyslog)
+AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf vasprintf gai_strerror hstrerror pstat setproctitle vsyslog)
dnl Checks for pg_config command.
AC_CHECK_PROGS(PGCONFIG, pg_config)
diff --git a/pool_error.c b/pool_error.c
index 4624d537e..982870beb 100644
--- a/pool_error.c
+++ b/pool_error.c
@@ -213,10 +213,24 @@ static char *nowsec(void)
#ifndef HAVE_VSYSLOG
void vsyslog (int priority, const char *format, va_list ap)
{
+#define MAXSYSLOGMSGLEN 1024
+
char *msg = NULL;
+
+#ifdef HAVE_VASPRINTF
vasprintf(&msg, format, ap);
if (!msg)
return;
+#else
+ msg = malloc(MAXSYSLOGMSGLEN);
+ if (!msg)
+ return;
+
+ va_start(ap, format);
+ vsnprintf(msg, MAXSYSLOGMSGLEN, format, ap);
+ va_end(ap);
+#endif
+
syslog(priority, "%s", msg);
free(msg);
}
[parent: 221dfb259ecf]