Change StatementCancelHandler() to check the DoingCommandRead flag to decide
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 26 Jan 2008 19:55:08 +0000 (19:55 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 26 Jan 2008 19:55:08 +0000 (19:55 +0000)
commit7e9eef33e60365f95cb686e743bd7f78db1b8b1e
treec33f06726a61f7f5cc36be66195dd8e94c791bf8
parentd75835a494e95a802ae49aa83a0ac0b4a82bcbf8
Change StatementCancelHandler() to check the DoingCommandRead flag to decide
whether to execute an immediate interrupt, rather than testing whether
LockWaitCancel() cancelled a lock wait.  The old way misclassified the case
where we were blocked in ProcWaitForSignal(), and arguably would misclassify
any other future additions of new ImmediateInterruptOK states too.  This
allows reverting the old kluge that gave LockWaitCancel() a return value,
since no callers care anymore.  Improve comments in the various
implementations of PGSemaphoreLock() to explain that on some platforms, the
assumption that semop() exits after a signal is wrong, and so we must ensure
that the signal handler itself throws elog if we want cancel or die interrupts
to be effective.  Per testing related to bug #3883, though this patch doesn't
solve those problems fully.

Perhaps this change should be back-patched, but since pre-8.3 branches aren't
really relying on autovacuum to respond to SIGINT, it doesn't seem critical
for them.
src/backend/port/posix_sema.c
src/backend/port/sysv_sema.c
src/backend/port/win32_sema.c
src/backend/storage/lmgr/proc.c
src/backend/tcop/postgres.c
src/include/storage/proc.h