OSDN Git Service

Use an always-there test, not an Assert, to check for overrun of
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Apr 2005 03:43:54 +0000 (03:43 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Apr 2005 03:43:54 +0000 (03:43 +0000)
the held_lwlocks[] array.  Per Qingqing Zhou.

src/backend/storage/lmgr/lwlock.c

index 444b04a..112690a 100644 (file)
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.25 2004/12/31 22:01:05 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.26 2005/04/08 03:43:54 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -328,7 +328,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
        SpinLockRelease_NoHoldoff(&lock->mutex);
 
        /* Add lock to list of locks held by this backend */
-       Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
+       if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
+               elog(ERROR, "too many LWLocks taken");
        held_lwlocks[num_held_lwlocks++] = lockid;
 
        /*
@@ -397,7 +398,8 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
        else
        {
                /* Add lock to list of locks held by this backend */
-               Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
+               if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
+                       elog(ERROR, "too many LWLocks taken");
                held_lwlocks[num_held_lwlocks++] = lockid;
        }