diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-10 12:20:30 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-10 12:22:21 -0400 |
commit | 4dab3d5ae1498eb4246e54225a48cf667ab693da (patch) | |
tree | c2d8c7d4bbfad019a14422ddb20f82aa540d1434 /src/backend/postmaster/pgarch.c | |
parent | 1f1b70a7cf957b88433f871f3732ad5701b6ad8b (diff) | |
download | postgresql-4dab3d5ae1498eb4246e54225a48cf667ab693da.tar.gz postgresql-4dab3d5ae1498eb4246e54225a48cf667ab693da.zip |
Change the autovacuum launcher to use WaitLatch instead of a poll loop.
In pursuit of this (and with the expectation that WaitLatch will be needed
in more places), convert the latch field that was already added to PGPROC
for sync rep into a generic latch that is activated for all PGPROC-owning
processes, and change many of the standard backend signal handlers to set
that latch when a signal happens. This will allow WaitLatch callers to be
wakened properly by these signals.
In passing, fix a whole bunch of signal handlers that had been hacked to do
things that might change errno, without adding the necessary save/restore
logic for errno. Also make some minor fixes in unix_latch.c, and clean
up bizarre and unsafe scheme for disowning the process's latch. Much of
this has to be back-patched into 9.1.
Peter Geoghegan, with additional work by Tom
Diffstat (limited to 'src/backend/postmaster/pgarch.c')
-rw-r--r-- | src/backend/postmaster/pgarch.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 8ccfc37fe9d..3cc7a59246b 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -288,16 +288,21 @@ pgarch_exit(SIGNAL_ARGS) static void ArchSigHupHandler(SIGNAL_ARGS) { + int save_errno = errno; + /* set flag to re-read config file at next convenient time */ got_SIGHUP = true; - /* let the waiting loop iterate */ SetLatch(&mainloop_latch); + + errno = save_errno; } /* SIGTERM signal handler for archiver process */ static void ArchSigTermHandler(SIGNAL_ARGS) { + int save_errno = errno; + /* * The postmaster never sends us SIGTERM, so we assume that this means * that init is trying to shut down the whole system. If we hang around @@ -305,28 +310,35 @@ ArchSigTermHandler(SIGNAL_ARGS) * archive commands. */ got_SIGTERM = true; - /* let the waiting loop iterate */ SetLatch(&mainloop_latch); + + errno = save_errno; } /* SIGUSR1 signal handler for archiver process */ static void pgarch_waken(SIGNAL_ARGS) { + int save_errno = errno; + /* set flag that there is work to be done */ wakened = true; - /* let the waiting loop iterate */ SetLatch(&mainloop_latch); + + errno = save_errno; } /* SIGUSR2 signal handler for archiver process */ static void pgarch_waken_stop(SIGNAL_ARGS) { + int save_errno = errno; + /* set flag to do a final cycle and shut down afterwards */ ready_to_stop = true; - /* let the waiting loop iterate */ SetLatch(&mainloop_latch); + + errno = save_errno; } /* |