]> granicus.if.org Git - postgresql/commitdiff
Remove bgw_sighup and bgw_sigterm.
authorRobert Haas <rhaas@postgresql.org>
Mon, 22 Jul 2013 18:13:00 +0000 (14:13 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 22 Jul 2013 19:15:22 +0000 (15:15 -0400)
Per discussion on pgsql-hackers, these aren't really needed.  Interim
versions of the background worker patch had the worker starting with
signals already unblocked, which would have made this necessary.
But the final version does not, so we don't really need it; and it
doesn't work well with the new facility for starting dynamic background
workers, so just rip it out.

Also per discussion on pgsql-hackers, back-patch this change to 9.3.
It's best to get the API break out of the way before we do an
official release of this facility, to avoid more pain for extension
authors later.

contrib/worker_spi/worker_spi.c
doc/src/sgml/bgworker.sgml
src/backend/postmaster/postmaster.c
src/include/postmaster/bgworker.h

index 414721a70fe9e43737d3b55c81ef10e34ba795e4..84ac1b7730b06bc8465862bcf15171883ea46af8 100644 (file)
@@ -159,6 +159,10 @@ worker_spi_main(void *main_arg)
        worktable  *table = (worktable *) main_arg;
        StringInfoData buf;
 
+       /* Establish signal handlers before unblocking signals. */
+       pqsignal(SIGHUP, worker_spi_sighup);
+       pqsignal(SIGTERM, worker_spi_sigterm);
+
        /* We're now ready to receive signals */
        BackgroundWorkerUnblockSignals();
 
@@ -328,8 +332,6 @@ _PG_init(void)
        worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
        worker.bgw_restart_time = BGW_NEVER_RESTART;
        worker.bgw_main = worker_spi_main;
-       worker.bgw_sighup = worker_spi_sighup;
-       worker.bgw_sigterm = worker_spi_sigterm;
 
        /*
         * Now fill in worker-specific data, and do the actual registrations.
index b0dde7564d86093e9aa4424ab562151e3ebb3f6f..7d2ffd14feff031b1bba4ffb385f60e2c731ddf9 100644 (file)
@@ -38,7 +38,6 @@
   The structure <structname>BackgroundWorker</structname> is defined thus:
 <programlisting>
 typedef void (*bgworker_main_type)(void *main_arg);
-typedef void (*bgworker_sighdlr_type)(SIGNAL_ARGS);
 typedef struct BackgroundWorker
 {
     char       *bgw_name;
@@ -47,8 +46,6 @@ typedef struct BackgroundWorker
     int         bgw_restart_time;       /* in seconds, or BGW_NEVER_RESTART */
     bgworker_main_type  bgw_main;
     void       *bgw_main_arg;
-    bgworker_sighdlr_type bgw_sighup;
-    bgworker_sighdlr_type bgw_sigterm;
 } BackgroundWorker;
 </programlisting>
   </para>
@@ -104,14 +101,6 @@ typedef struct BackgroundWorker
    passed at registration time.
   </para>
 
-  <para>
-   <structfield>bgw_sighup</structfield> and <structfield>bgw_sigterm</> are
-   pointers to functions that will be installed as signal handlers for the new
-   process.  If <structfield>bgw_sighup</> is NULL, then <literal>SIG_IGN</>
-   is used; if <structfield>bgw_sigterm</> is NULL, a handler is installed that
-   will terminate the process after logging a suitable message.
-  </para>
-
   <para>Once running, the process can connect to a database by calling
    <function>BackgroundWorkerInitializeConnection(<parameter>char *dbname</parameter>, <parameter>char *username</parameter>)</function>.
    This allows the process to run transactions and queries using the
@@ -126,7 +115,7 @@ typedef struct BackgroundWorker
   <para>
    Signals are initially blocked when control reaches the
    <structfield>bgw_main</> function, and must be unblocked by it; this is to
-   allow the process to further customize its signal handlers, if necessary.
+   allow the process to customize its signal handlers, if necessary.
    Signals can be unblocked in the new process by calling
    <function>BackgroundWorkerUnblockSignals</> and blocked by calling
    <function>BackgroundWorkerBlockSignals</>.
index ec2677380bf6d26437e17515f2afb8dd4ab75594..1e41a0e75ec0ce1320276a46e7b100cf7099d512 100644 (file)
@@ -5434,16 +5434,8 @@ do_start_bgworker(void)
                pqsignal(SIGFPE, SIG_IGN);
        }
 
-       /* SIGTERM and SIGHUP are configurable */
-       if (worker->bgw_sigterm)
-               pqsignal(SIGTERM, worker->bgw_sigterm);
-       else
-               pqsignal(SIGTERM, bgworker_die);
-
-       if (worker->bgw_sighup)
-               pqsignal(SIGHUP, worker->bgw_sighup);
-       else
-               pqsignal(SIGHUP, SIG_IGN);
+       pqsignal(SIGTERM, bgworker_die);
+       pqsignal(SIGHUP, SIG_IGN);
 
        pqsignal(SIGQUIT, bgworker_quickdie);
        InitializeTimeouts();           /* establishes SIGALRM handler */
index 53167057e9a4d6d499ec0b7a60adafc3e0ce1fc8..e91e344eb67856854e6773262124a6757f3a93c2 100644 (file)
@@ -53,7 +53,6 @@
 
 
 typedef void (*bgworker_main_type) (void *main_arg);
-typedef void (*bgworker_sighdlr_type) (SIGNAL_ARGS);
 
 /*
  * Points in time at which a bgworker can request to be started
@@ -76,8 +75,6 @@ typedef struct BackgroundWorker
        int                     bgw_restart_time;               /* in seconds, or BGW_NEVER_RESTART */
        bgworker_main_type bgw_main;
        void       *bgw_main_arg;
-       bgworker_sighdlr_type bgw_sighup;
-       bgworker_sighdlr_type bgw_sigterm;
 } BackgroundWorker;
 
 /* Register a new bgworker */