aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-12-29 18:29:18 +0000
committerBruce Momjian <bruce@momjian.us>1998-12-29 18:29:18 +0000
commitf659ec545f6515d158c6ba3942e1fa2016dc59d6 (patch)
tree3bb1a0134222e78416b92191daf91870f916ed52
parent550de5db2c36badc508d8d6116643fef994b9c38 (diff)
downloadpostgresql-f659ec545f6515d158c6ba3942e1fa2016dc59d6.tar.gz
postgresql-f659ec545f6515d158c6ba3942e1fa2016dc59d6.zip
Fix for deadlock timer timeout.
-rw-r--r--src/backend/storage/lmgr/proc.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 74adf58a4de..095ac87a06f 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.44 1998/12/18 19:45:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.45 1998/12/29 18:29:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,7 +46,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.44 1998/12/18 19:45:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.45 1998/12/29 18:29:18 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
@@ -449,7 +449,6 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
int i;
bool deadlock_checked = false;
PROC *proc;
- struct timeval timeval;
/*
* If the first entries in the waitQueue have a greater priority than
@@ -513,29 +512,24 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
SpinRelease(spinlock);
/* --------------
- * We set this so we can wake up periodically and check for a deadlock.
+ * We set this so we can wake up after one second to check for a deadlock.
* If a deadlock is detected, the handler releases the processes
* semaphore and aborts the current transaction.
- *
- * Need to zero out struct to set the interval and the micro seconds fields
- * to 0.
* --------------
*/
- MemSet(&timeval, 0, sizeof(struct timeval));
- timeval.tv_sec = \
- (DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
do
{
- int expire;
+ int expired;
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
- if ((expire = select(0, NULL, NULL, NULL,
- (deadlock_checked == false) ? &timeval : NULL)) == -1)
- elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
+ if (deadlock_checked == false)
+ expired = sleep(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
+ else
+ pause();
- if (expire == 0 /* timeout reached */ && deadlock_checked == false)
+ if (expired == 0 && deadlock_checked == false)
{
HandleDeadLock();
deadlock_checked = true;