]> granicus.if.org Git - postgresql/commitdiff
Fix SIGUSR1 handling by unconnected bgworkers
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 10 Apr 2013 19:01:16 +0000 (16:01 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 10 Apr 2013 19:01:16 +0000 (16:01 -0300)
Latch activity was not being detected by non-database-connected workers; the
SIGUSR1 signal handler which is normally in charge of that was set to SIG_IGN.
Create a simple handler to call latch_sigusr1_handler instead.

Robert Haas (bug report and suggested fix)

src/backend/postmaster/postmaster.c

index 5ff35774787f0be96d4bdf6adbdfd0d363537267..474e17e9218945ad2b8b5f7e2e20989a5fc679ee 100644 (file)
@@ -5354,6 +5354,22 @@ bgworker_die(SIGNAL_ARGS)
                                        MyBgworkerEntry->bgw_name)));
 }
 
+/*
+ * Standard SIGUSR1 handler for unconnected workers
+ *
+ * Here, we want to make sure an unconnected worker will at least heed
+ * latch activity.
+ */
+static void
+bgworker_sigusr1_handler(SIGNAL_ARGS)
+{
+       int                     save_errno = errno;
+
+       latch_sigusr1_handler();
+
+       errno = save_errno;
+}
+
 static void
 do_start_bgworker(void)
 {
@@ -5410,7 +5426,7 @@ do_start_bgworker(void)
        else
        {
                pqsignal(SIGINT, SIG_IGN);
-               pqsignal(SIGUSR1, SIG_IGN);
+               pqsignal(SIGUSR1, bgworker_sigusr1_handler);
                pqsignal(SIGFPE, SIG_IGN);
        }