]> 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 18:13:00 +0000 (14:13 -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/bgworker.c
src/backend/postmaster/postmaster.c
src/include/postmaster/bgworker.h

index ef19e4b39ebc85be00f3688abf0dfd97144a5b36..14b5045caa487e6ac058870adc326a7939ce75f5 100644 (file)
@@ -344,8 +344,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 = NULL;
-       worker.bgw_sigterm = NULL;
 
        /*
         * Now fill in worker-specific data, and do the actual registrations.
@@ -375,8 +373,6 @@ worker_spi_launch(PG_FUNCTION_ARGS)
        worker.bgw_main = NULL;         /* new worker might not have library loaded */
        sprintf(worker.bgw_library_name, "worker_spi");
        sprintf(worker.bgw_function_name, "worker_spi_main");
-       worker.bgw_sighup = NULL;       /* new worker might not have library loaded */
-       worker.bgw_sigterm = NULL;      /* new worker might not have library loaded */
        snprintf(worker.bgw_name, BGW_MAXLEN, "worker %d", i);
        worker.bgw_main_arg = Int32GetDatum(i);
 
index 9d9b631ac1ad74386769263031c39f2a4d976dca..268e1cd2153ae903884bb048296457764a1cf61f 100644 (file)
@@ -48,7 +48,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[BGW_MAXLEN];
@@ -59,8 +58,6 @@ typedef struct BackgroundWorker
     char        bgw_library_name[BGW_MAXLEN];   /* only if bgw_main is NULL */
     char        bgw_function_name[BGW_MAXLEN];  /* only if bgw_main is NULL */
     Datum       bgw_main_arg;
-    bgworker_sighdlr_type bgw_sighup;
-    bgworker_sighdlr_type bgw_sigterm;
 } BackgroundWorker;
 </programlisting>
   </para>
@@ -138,17 +135,6 @@ typedef struct BackgroundWorker
    <structfield>bgw_main</structfield> is NULL.
   </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.  These
-   fields should not be used if <structfield>bgw_main</> is NULL; instead,
-   the worker process should set its own signal handlers before calling
-   <function>BackgroundWorkerUnblockSignals()</function>.
-  </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
@@ -163,7 +149,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 3728d85486d3223569278f71755e178109e87d54..ada24e905e61971ef4f3ad31281f61d3c6f545a8 100644 (file)
@@ -247,8 +247,6 @@ BackgroundWorkerStateChange(void)
                rw->rw_worker.bgw_restart_time = slot->worker.bgw_restart_time;
                rw->rw_worker.bgw_main = slot->worker.bgw_main;
                rw->rw_worker.bgw_main_arg = slot->worker.bgw_main_arg;
-               rw->rw_worker.bgw_sighup = slot->worker.bgw_sighup;
-               rw->rw_worker.bgw_sigterm = slot->worker.bgw_sigterm;
 
                /* Initialize postmaster bookkeeping. */
                rw->rw_backend = NULL;
index d9b800c4e701054b8f41cda6ecff2b73aa5b6d65..7894217ed5288dc3c232f0f957881c910428867a 100644 (file)
@@ -5357,17 +5357,8 @@ do_start_bgworker(void)
                pqsignal(SIGUSR1, bgworker_sigusr1_handler);
                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 794eb3907256915e3507e6761586e251e1fd91e3..b260dc5e4e8adb1afc2825b1145c61dcad277340 100644 (file)
@@ -53,7 +53,6 @@
 
 
 typedef void (*bgworker_main_type) (Datum main_arg);
-typedef void (*bgworker_sighdlr_type) (SIGNAL_ARGS);
 
 /*
  * Points in time at which a bgworker can request to be started
@@ -79,8 +78,6 @@ typedef struct BackgroundWorker
        char            bgw_library_name[BGW_MAXLEN];   /* only if bgw_main is NULL */
        char            bgw_function_name[BGW_MAXLEN];  /* only if bgw_main is NULL */
        Datum           bgw_main_arg;
-       bgworker_sighdlr_type bgw_sighup;
-       bgworker_sighdlr_type bgw_sigterm;
 } BackgroundWorker;
 
 /* Register a new bgworker during shared_preload_libraries */