summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2000-02-24 04:36:01 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2000-02-24 04:36:01 +0000
commitf017d7eeeeb14a2b8690299bd5389c67bc82b3da (patch)
tree3d94acd81f27bb87af664a605badf6cffdac04ad
parenta5e944580f55d686002e2b25ad56861a2dab55c2 (diff)
Check pending cancel request before waiting for lock
-rw-r--r--src/backend/storage/lmgr/proc.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 4e377d6498c..5e169114c3e 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.69 2000/02/22 09:55:20 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.70 2000/02/24 04:36:01 inoue Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,7 @@
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
*
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.69 2000/02/22 09:55:20 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.70 2000/02/24 04:36:01 inoue Exp $
*/
#include <sys/time.h>
#include <unistd.h>
@@ -481,10 +481,28 @@ ProcQueueInit(PROC_QUEUE *queue)
}
+/*
+ * Handling cancel request while waiting for lock
+ *
+ */
static bool lockWaiting = false;
void SetWaitingForLock(bool waiting)
{
+ if (waiting == lockWaiting)
+ return;
lockWaiting = waiting;
+ if (lockWaiting)
+ {
+ Assert(MyProc->links.next != INVALID_OFFSET);
+ if (QueryCancel) /* cancel request pending */
+ {
+ if (GetOffWaitqueue(MyProc))
+ {
+ lockWaiting = false;
+ elog(ERROR, "Query cancel requested while waiting lock");
+ }
+ }
+ }
}
void LockWaitCancel(void)
{
@@ -610,7 +628,7 @@ ins:;
timeval.it_value.tv_sec = \
(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
- lockWaiting = true;
+ SetWaitingForLock(true);
do
{
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */