aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-08-10 12:20:30 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-08-10 12:22:21 -0400
commit4dab3d5ae1498eb4246e54225a48cf667ab693da (patch)
treec2d8c7d4bbfad019a14422ddb20f82aa540d1434 /src/backend/tcop/postgres.c
parent1f1b70a7cf957b88433f871f3732ad5701b6ad8b (diff)
downloadpostgresql-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/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index f035a48e9b4..ed815d137c0 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2643,11 +2643,12 @@ die(SIGNAL_ARGS)
InterruptHoldoffCount--;
ProcessInterrupts();
}
-
- /* Interrupt any sync rep wait which is currently in progress. */
- SetLatch(&(MyProc->waitLatch));
}
+ /* If we're still here, waken anything waiting on the process latch */
+ if (MyProc)
+ SetLatch(&MyProc->procLatch);
+
errno = save_errno;
}
@@ -2684,11 +2685,12 @@ StatementCancelHandler(SIGNAL_ARGS)
InterruptHoldoffCount--;
ProcessInterrupts();
}
-
- /* Interrupt any sync rep wait which is currently in progress. */
- SetLatch(&(MyProc->waitLatch));
}
+ /* If we're still here, waken anything waiting on the process latch */
+ if (MyProc)
+ SetLatch(&MyProc->procLatch);
+
errno = save_errno;
}
@@ -2696,6 +2698,7 @@ StatementCancelHandler(SIGNAL_ARGS)
void
FloatExceptionHandler(SIGNAL_ARGS)
{
+ /* We're not returning, so no need to save errno */
ereport(ERROR,
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
errmsg("floating-point exception"),
@@ -2708,7 +2711,13 @@ FloatExceptionHandler(SIGNAL_ARGS)
static void
SigHupHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
got_SIGHUP = true;
+ if (MyProc)
+ SetLatch(&MyProc->procLatch);
+
+ errno = save_errno;
}
/*