*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.67 2000/01/26 05:57:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.68 2000/02/21 02:42:36 inoue Exp $
*
*-------------------------------------------------------------------------
*/
* 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.67 2000/01/26 05:57:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.68 2000/02/21 02:42:36 inoue Exp $
*/
#include <sys/time.h>
#include <unistd.h>
on_shmem_exit(ProcKill, (caddr_t) MyProcPid);
}
+/* -----------------------
+ * get off the wait queue
+ * -----------------------
+ */
+static void
+GetOffWaitqueue(PROC *proc)
+{
+ LockLockTable();
+ if (proc->links.next != INVALID_OFFSET)
+ {
+ int lockmode = proc->token;
+ Assert(proc->waitLock->waitProcs.size > 0);
+ SHMQueueDelete(&(proc->links));
+ --proc->waitLock->waitProcs.size;
+ Assert(proc->waitLock->nHolding > 0);
+ Assert(proc->waitLock->nHolding > proc->waitLock->nActive);
+ --proc->waitLock->nHolding;
+ Assert(proc->waitLock->holders[lockmode] > 0);
+ --proc->waitLock->holders[lockmode];
+ if (proc->waitLock->activeHolders[lockmode] ==
+ proc->waitLock->holders[lockmode])
+ proc->waitLock->waitMask &= ~(1 << lockmode);
+ }
+ SHMQueueElemInit(&(proc->links));
+ UnlockLockTable();
+
+ return;
+}
/*
* ProcReleaseLocks() -- release all locks associated with this process
*
if (!MyProc)
return;
LockReleaseAll(1, &MyProc->lockQueue);
+ GetOffWaitqueue(MyProc);
}
/*
* get off the wait queue
* ----------------
*/
- LockLockTable();
- if (proc->links.next != INVALID_OFFSET)
- {
- Assert(proc->waitLock->waitProcs.size > 0);
- SHMQueueDelete(&(proc->links));
- --proc->waitLock->waitProcs.size;
- }
- SHMQueueElemInit(&(proc->links));
- UnlockLockTable();
+ GetOffWaitqueue(proc);
return;
}
timeval.it_value.tv_sec = \
(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
+ SetLockWaiting(true);
do
{
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
IpcExclusiveLock);
} while (MyProc->errType == STATUS_NOT_FOUND); /* sleep after deadlock
* check */
+ SetLockWaiting(false);
/* ---------------
* We were awoken before a timeout - now disable the timer
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.144 2000/02/20 04:26:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.145 2000/02/21 02:42:35 inoue Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
}
+static bool lockWaiting = false;
+void SetLockWaiting(bool waiting)
+{
+ lockWaiting = waiting;
+}
/* signal handler for query cancel signal from postmaster */
static void
QueryCancelHandler(SIGNAL_ARGS)
{
QueryCancel = true;
+ if (lockWaiting)
+ {
+ lockWaiting = false;
+ elog(ERROR, "Query Cancel requested while waiting lock");
+ }
}
void
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.144 $ $Date: 2000/02/20 04:26:35 $\n");
+ puts("$Revision: 1.145 $ $Date: 2000/02/21 02:42:35 $\n");
}
/*
firstchar = ReadCommand(parser_input);
QueryCancel = false; /* forget any earlier CANCEL signal */
+ lockWaiting = false;
/* ----------------
* (4) disable async.c's signal handler.
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.51 2000/02/18 09:29:06 inoue Exp $
+ * $Id: miscadmin.h,v 1.52 2000/02/21 02:42:37 inoue Exp $
*
* NOTES
* some of the information in this file will be moved to
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
+extern void SetLockWaiting(bool);
/*
* "postmaster.pid" is a file containing postmaster's pid, being