From 48477283a5d5681a92c167d566e7b2594847fac8 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sat, 31 Mar 2012 18:51:57 +0900 Subject: [PATCH] Fix deadlock by enabling log_destination = syslog reported in bug 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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pool_error.c b/pool_error.c index d0f4f7c76..cae55ca60 100644 --- a/pool_error.c +++ b/pool_error.c @@ -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); -- 2.39.5