Minor fix in lwlock.c

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-patches(at)postgresql(dot)org
Subject: Minor fix in lwlock.c
Date: 2005-04-08 02:21:53
Message-ID: d34pvh$2tbh$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

The chance that num_held_lwlocks is beyond MAX_SIMUL_LWLOCKS is similar to
the chance that failed to grasp a spinlock in 1 minute, so they should be
treated in the same way. This is mainly to prevent programming error (e.g.,
forget to release the LWLocks).

Regards,
Qingqing

---

Index: lwlock.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v
retrieving revision 1.25
diff -c -r1.25 lwlock.c
*** lwlock.c 31 Dec 2004 22:01:05 -0000 1.25
--- lwlock.c 8 Apr 2005 02:19:31 -0000
***************
*** 328,334 ****
SpinLockRelease_NoHoldoff(&lock->mutex);

/* Add lock to list of locks held by this backend */
! Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
held_lwlocks[num_held_lwlocks++] = lockid;

/*
--- 328,335 ----
SpinLockRelease_NoHoldoff(&lock->mutex);

/* Add lock to list of locks held by this backend */
! if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
! elog(FATAL, "Too many LWLocks");
held_lwlocks[num_held_lwlocks++] = lockid;

/*
***************
*** 397,403 ****
else
{
/* Add lock to list of locks held by this backend */
! Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
held_lwlocks[num_held_lwlocks++] = lockid;
}

--- 398,405 ----
else
{
/* Add lock to list of locks held by this backend */
! if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
! elog(FATAL, "Too many LWLocks");
held_lwlocks[num_held_lwlocks++] = lockid;
}

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-04-08 03:47:26 Re: Minor fix in lwlock.c
Previous Message Neil Conway 2005-04-08 01:00:28 Re: add_missing_from = false