? potential bug in LockBuffer ?

From: "Mauricio Breternitz" <mbjsql(at)hotmail(dot)com>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: ? potential bug in LockBuffer ?
Date: 2001-05-22 20:40:16
Message-ID: F166XCj303wxNaJkGuS0000f852@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Folks:
As I study the source of LockBuffer in bufmgr.c I came across
the following code snippet for the case of releasing a
shared (read) lock:

if (mode == BUFFER_LOCK_UNLOCK)
{
if (*buflock & BL_R_LOCK)
{
Assert(buf->r_locks > 0);
Assert(!(buf->w_lock));
Assert(!(*buflock & (BL_W_LOCK | BL_RI_LOCK)));
(buf->r_locks)--;
*buflock &= ~BL_R_LOCK;

This code resets BL_R_LOCK on the first release of a shared lock.
I think it should check that the count of readers be zero:
( something like

if (mode == BUFFER_LOCK_UNLOCK)
{
if (*buflock & BL_R_LOCK)
{
Assert(buf->r_locks > 0);
Assert(!(buf->w_lock));
Assert(!(*buflock & (BL_W_LOCK | BL_RI_LOCK)));
(buf->r_locks)--;
if (!buf->r_locks)
*buflock &= ~BL_R_LOCK;

Or I am missing something...

thanks
regards
Mauricio
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikheev, Vadim 2001-05-22 20:57:14 RE: ? potential bug in LockBuffer ?
Previous Message Peter Eisentraut 2001-05-22 20:35:18 Re: SEP_CHAR