Remove pool_log/pool_error calls from signal handlers.
authorTatsuo Ishii <ishii@postgresql.org>
Wed, 11 Jan 2017 00:38:16 +0000 (09:38 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Wed, 11 Jan 2017 00:38:16 +0000 (09:38 +0900)
pool_log/pool_error calls malloc(), which is not safe to be called
inside signal handlers, per discussion in [pgpool-hackers: 1950].  I
ifdef out them, rather than simply remove them in a hope we someday
find a better solution which make calling the functions inside signal
handlers.

Not that I did not touch exit_handler() of pgpool_main.c because
removing pool_log/pool_debug from them loses informative message like
"received smart shutdown request". Pgpool-II main process do not
heavily use malloc(), so the risk is minimum, I guess.

child.c
main.c

diff --git a/child.c b/child.c
index 5942a9f31769390f134a4e756162404a6fd6b646..0a7b097cfe96649618950729514550f23744976e 100644 (file)
--- a/child.c
+++ b/child.c
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2016     PgPool Global Development Group
+ * Copyright (c) 2003-2017     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -1285,15 +1285,19 @@ static RETSIGTYPE die(int sig)
                        /* Refuse further requests by closing listen socket */
                        if (child_inet_fd)
                        {
+#ifdef NOT_USED
                                pool_log("die: close listen socket");
+#endif
                                close(child_inet_fd);
                        }
                        close(child_unix_fd);
 
+#ifdef NOT_USED
                        if (idle == 0)
                        {
                                pool_debug("child receives smart shutdown request but it's not in idle state");
                        }
+#endif
                        break;
 
                case SIGINT:    /* fast shutdown */
@@ -1301,7 +1305,9 @@ static RETSIGTYPE die(int sig)
                        child_exit(0);
                        break;
                default:
+#ifdef NOT_USED
                        pool_error("die() received unknown signal: %d", sig);
+#endif
                        break;
        }
 }
@@ -1316,7 +1322,9 @@ static RETSIGTYPE close_idle_connection(int sig)
        POOL_CONNECTION_POOL *p = pool_connection_pool;
        ConnectionInfo *info;
 
+#ifdef NOT_USED
        pool_debug("child receives close connection request");
+#endif
 
        for (j=0;j<pool_config->max_pool;j++, p++)
        {
@@ -1441,7 +1449,9 @@ void child_exit(int code)
 {
        if (getpid() == mypid)
        {
+#ifdef NOT_USED
                pool_log("child_exit: called from pgpool main. ignored.");
+#endif
                return;
        }
 
diff --git a/main.c b/main.c
index d06de306b37ef91ed393824b3d1916834fd39eb0..352041fb352974d5179720cf78b77f2405f004e4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2016     PgPool Global Development Group
+ * Copyright (c) 2003-2017     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby