Fix deadlock by enabling log_destination = syslog reported in bug
authorTatsuo Ishii <ishii@postgresql.org>
Sat, 31 Mar 2012 09:51:57 +0000 (18:51 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sat, 31 Mar 2012 09:51:57 +0000 (18:51 +0900)
tracker http://www.pgpool.net/mantisbt/view.php?id=9.  The workaround
is blocking signal before calling vsyslog in pool_log etc. This has
been already done log_destination = stderr case. Patch provided by
Gilles Darold.

Committed to master and  V3_1_STABLE.

pool_error.c

index d0f4f7c7625c74baa0fd39c73d3fadb0d4b363f3..cae55ca601a6441ac6ead555418f1bbeabe82f18 100644 (file)
@@ -5,7 +5,11 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
+<<<<<<< HEAD
  * Copyright (c) 2003-2010     PgPool Global Development Group
+=======
+ * Copyright (c) 2003-2012     PgPool Global Development Group
+>>>>>>> d2f39cc... Fix deadlock by enabling log_destination = syslog reported in bug
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -50,16 +54,17 @@ void pool_error(const char *fmt,...)
 #else
        int     oldmask;
 #endif
+       POOL_SETMASK2(&BlockSig, &oldmask);
+
        /* 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);
+          POOL_SETMASK(&oldmask);
           return;
        }
 
-       POOL_SETMASK2(&BlockSig, &oldmask);
-
        if (pool_config->print_timestamp)
 #ifdef HAVE_ASPRINTF
          len = asprintf(&fmt2, "%s ERROR: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
@@ -112,16 +117,18 @@ void pool_debug(const char *fmt,...)
                if (pool_config->debug_level <= 0)
                        return;
        }
+
+       POOL_SETMASK2(&BlockSig, &oldmask);
+
        /* Write debug message to syslog */
        if (pool_config->logsyslog == 1) {
           va_start(ap, fmt);
           vsyslog(pool_config->syslog_facility | LOG_DEBUG, fmt, ap);
           va_end(ap);
+          POOL_SETMASK(&oldmask);
           return;
        }
 
-       POOL_SETMASK2(&BlockSig, &oldmask);
-
        if (pool_config->print_timestamp)
 #ifdef HAVE_ASPRINTF
          len = asprintf(&fmt2, "%s DEBUG: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
@@ -163,16 +170,18 @@ void pool_log(const char *fmt,...)
 #else
        int     oldmask;
 #endif
+
+       POOL_SETMASK2(&BlockSig, &oldmask);
+
        /* Write log message to syslog */
        if (pool_config->logsyslog == 1) {
           va_start(ap, fmt);
           vsyslog(pool_config->syslog_facility | LOG_NOTICE, fmt, ap);
           va_end(ap);
+          POOL_SETMASK(&oldmask);
           return;
        }
 
-       POOL_SETMASK2(&BlockSig, &oldmask);
-
        if (pool_config->print_timestamp)
 #ifdef HAVE_ASPRINTF
          len = asprintf(&fmt2, "%s LOG:   pid %d: %s\n", nowsec(), (int)getpid(), fmt);