Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f40a318

Browse files
committed
Remove bgw_sighup and bgw_sigterm.
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.
1 parent 0518ece commit f40a318

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

contrib/worker_spi/worker_spi.c

-4
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ _PG_init(void)
344344
worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
345345
worker.bgw_restart_time = BGW_NEVER_RESTART;
346346
worker.bgw_main = worker_spi_main;
347-
worker.bgw_sighup = NULL;
348-
worker.bgw_sigterm = NULL;
349347

350348
/*
351349
* Now fill in worker-specific data, and do the actual registrations.
@@ -375,8 +373,6 @@ worker_spi_launch(PG_FUNCTION_ARGS)
375373
worker.bgw_main = NULL; /* new worker might not have library loaded */
376374
sprintf(worker.bgw_library_name, "worker_spi");
377375
sprintf(worker.bgw_function_name, "worker_spi_main");
378-
worker.bgw_sighup = NULL; /* new worker might not have library loaded */
379-
worker.bgw_sigterm = NULL; /* new worker might not have library loaded */
380376
snprintf(worker.bgw_name, BGW_MAXLEN, "worker %d", i);
381377
worker.bgw_main_arg = Int32GetDatum(i);
382378

doc/src/sgml/bgworker.sgml

+1-15
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
The structure <structname>BackgroundWorker</structname> is defined thus:
4949
<programlisting>
5050
typedef void (*bgworker_main_type)(void *main_arg);
51-
typedef void (*bgworker_sighdlr_type)(SIGNAL_ARGS);
5251
typedef struct BackgroundWorker
5352
{
5453
char bgw_name[BGW_MAXLEN];
@@ -59,8 +58,6 @@ typedef struct BackgroundWorker
5958
char bgw_library_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
6059
char bgw_function_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
6160
Datum bgw_main_arg;
62-
bgworker_sighdlr_type bgw_sighup;
63-
bgworker_sighdlr_type bgw_sigterm;
6461
} BackgroundWorker;
6562
</programlisting>
6663
</para>
@@ -138,17 +135,6 @@ typedef struct BackgroundWorker
138135
<structfield>bgw_main</structfield> is NULL.
139136
</para>
140137

141-
<para>
142-
<structfield>bgw_sighup</structfield> and <structfield>bgw_sigterm</> are
143-
pointers to functions that will be installed as signal handlers for the new
144-
process. If <structfield>bgw_sighup</> is NULL, then <literal>SIG_IGN</>
145-
is used; if <structfield>bgw_sigterm</> is NULL, a handler is installed that
146-
will terminate the process after logging a suitable message. These
147-
fields should not be used if <structfield>bgw_main</> is NULL; instead,
148-
the worker process should set its own signal handlers before calling
149-
<function>BackgroundWorkerUnblockSignals()</function>.
150-
</para>
151-
152138
<para>Once running, the process can connect to a database by calling
153139
<function>BackgroundWorkerInitializeConnection(<parameter>char *dbname</parameter>, <parameter>char *username</parameter>)</function>.
154140
This allows the process to run transactions and queries using the
@@ -163,7 +149,7 @@ typedef struct BackgroundWorker
163149
<para>
164150
Signals are initially blocked when control reaches the
165151
<structfield>bgw_main</> function, and must be unblocked by it; this is to
166-
allow the process to further customize its signal handlers, if necessary.
152+
allow the process to customize its signal handlers, if necessary.
167153
Signals can be unblocked in the new process by calling
168154
<function>BackgroundWorkerUnblockSignals</> and blocked by calling
169155
<function>BackgroundWorkerBlockSignals</>.

src/backend/postmaster/bgworker.c

-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ BackgroundWorkerStateChange(void)
247247
rw->rw_worker.bgw_restart_time = slot->worker.bgw_restart_time;
248248
rw->rw_worker.bgw_main = slot->worker.bgw_main;
249249
rw->rw_worker.bgw_main_arg = slot->worker.bgw_main_arg;
250-
rw->rw_worker.bgw_sighup = slot->worker.bgw_sighup;
251-
rw->rw_worker.bgw_sigterm = slot->worker.bgw_sigterm;
252250

253251
/* Initialize postmaster bookkeeping. */
254252
rw->rw_backend = NULL;

src/backend/postmaster/postmaster.c

+2-11
Original file line numberDiff line numberDiff line change
@@ -5357,17 +5357,8 @@ do_start_bgworker(void)
53575357
pqsignal(SIGUSR1, bgworker_sigusr1_handler);
53585358
pqsignal(SIGFPE, SIG_IGN);
53595359
}
5360-
5361-
/* SIGTERM and SIGHUP are configurable */
5362-
if (worker->bgw_sigterm)
5363-
pqsignal(SIGTERM, worker->bgw_sigterm);
5364-
else
5365-
pqsignal(SIGTERM, bgworker_die);
5366-
5367-
if (worker->bgw_sighup)
5368-
pqsignal(SIGHUP, worker->bgw_sighup);
5369-
else
5370-
pqsignal(SIGHUP, SIG_IGN);
5360+
pqsignal(SIGTERM, bgworker_die);
5361+
pqsignal(SIGHUP, SIG_IGN);
53715362

53725363
pqsignal(SIGQUIT, bgworker_quickdie);
53735364
InitializeTimeouts(); /* establishes SIGALRM handler */

src/include/postmaster/bgworker.h

-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454

5555
typedef void (*bgworker_main_type) (Datum main_arg);
56-
typedef void (*bgworker_sighdlr_type) (SIGNAL_ARGS);
5756

5857
/*
5958
* Points in time at which a bgworker can request to be started
@@ -79,8 +78,6 @@ typedef struct BackgroundWorker
7978
char bgw_library_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
8079
char bgw_function_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
8180
Datum bgw_main_arg;
82-
bgworker_sighdlr_type bgw_sighup;
83-
bgworker_sighdlr_type bgw_sigterm;
8481
} BackgroundWorker;
8582

8683
/* Register a new bgworker during shared_preload_libraries */

0 commit comments

Comments
 (0)