iBrought in a fix for backend crashes
Submitted by: "Vadim B. Mikheev" <vadim@sable.krasnoyarsk.su>
This commit is contained in:
parent
00fe588fb0
commit
b619cb09d9
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: buf_internals.h,v 1.2 1996/07/22 22:59:42 scrappy Exp $
|
||||
* $Id: buf_internals.h,v 1.3 1996/07/23 05:43:11 scrappy Exp $
|
||||
*
|
||||
* NOTE
|
||||
* If BUFFERPAGE0 is defined, then 0 will be used as a
|
||||
@ -118,8 +118,8 @@ struct sbufdesc {
|
||||
int16 bufsmgr; /* storage manager id for buffer */
|
||||
unsigned refcount; /* # of times buffer is pinned */
|
||||
|
||||
char *sb_dbname; /* name of db in which buf belongs */
|
||||
char *sb_relname; /* name of reln */
|
||||
char sb_dbname[NAMEDATALEN+1]; /* name of db in which buf belongs */
|
||||
char sb_relname[NAMEDATALEN+1]; /* name of reln */
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
/* can afford a dedicated lock if test-and-set locks are available */
|
||||
slock_t io_in_progress_lock;
|
||||
@ -164,7 +164,7 @@ struct sbufdesc {
|
||||
|
||||
#if defined(PORTNAME_BSD44_derived) || \
|
||||
defined(PORTNAME_bsdi) || \
|
||||
defined(PORTNAME_i86pc_solaris) || \
|
||||
defined(PORTNAME_i386_solaris) || \
|
||||
defined(PORTNAME_linux) || \
|
||||
defined(PORTNAME_sparc) || \
|
||||
defined(PORTNAME_sparc_solaris)
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.1.1.1 1996/07/09 06:21:54 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.2 1996/07/23 05:44:10 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -485,20 +485,23 @@ BufferAlloc(Relation reln,
|
||||
}
|
||||
}
|
||||
|
||||
if ( buf != NULL )
|
||||
{
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
S_UNLOCK(&(buf->io_in_progress_lock));
|
||||
S_UNLOCK(&(buf->io_in_progress_lock));
|
||||
#else /* !HAS_TEST_AND_SET */
|
||||
if (buf->refcount > 1)
|
||||
SignalIO(buf);
|
||||
if (buf->refcount > 1)
|
||||
SignalIO(buf);
|
||||
#endif /* !HAS_TEST_AND_SET */
|
||||
|
||||
/* give up the buffer since we don't need it any more */
|
||||
buf->refcount--;
|
||||
PrivateRefCount[BufferDescriptorGetBuffer(buf) - 1] = 0;
|
||||
AddBufferToFreelist(buf);
|
||||
buf->flags |= BM_FREE;
|
||||
buf->flags &= ~BM_DIRTY;
|
||||
buf->flags &= ~BM_IO_IN_PROGRESS;
|
||||
buf->refcount--;
|
||||
PrivateRefCount[BufferDescriptorGetBuffer(buf) - 1] = 0;
|
||||
AddBufferToFreelist(buf);
|
||||
buf->flags |= BM_FREE;
|
||||
buf->flags &= ~BM_DIRTY;
|
||||
buf->flags &= ~BM_IO_IN_PROGRESS;
|
||||
}
|
||||
|
||||
SpinRelease(BufMgrLock);
|
||||
|
||||
@ -537,8 +540,8 @@ BufferAlloc(Relation reln,
|
||||
}
|
||||
|
||||
/* record the database name and relation name for this buffer */
|
||||
buf->sb_relname = pstrdup(reln->rd_rel->relname.data);
|
||||
buf->sb_dbname = pstrdup(GetDatabaseName());
|
||||
strcpy (buf->sb_relname, reln->rd_rel->relname.data);
|
||||
strcpy (buf->sb_dbname, GetDatabaseName());
|
||||
|
||||
/* remember which storage manager is responsible for it */
|
||||
buf->bufsmgr = reln->rd_rel->relsmgr;
|
||||
@ -1248,7 +1251,7 @@ PrintBufferDescs()
|
||||
elog(NOTICE, "[%02d] (freeNext=%d, freePrev=%d, relname=%.*s, \
|
||||
blockNum=%d, flags=0x%x, refcount=%d %d)",
|
||||
i, buf->freeNext, buf->freePrev, NAMEDATALEN,
|
||||
&(buf->sb_relname), buf->tag.blockNum, buf->flags,
|
||||
buf->sb_relname, buf->tag.blockNum, buf->flags,
|
||||
buf->refcount, PrivateRefCount[i]);
|
||||
}
|
||||
SpinRelease(BufMgrLock);
|
||||
@ -1273,7 +1276,7 @@ PrintPinnedBufs()
|
||||
if (PrivateRefCount[i] > 0)
|
||||
elog(NOTICE, "[%02d] (freeNext=%d, freePrev=%d, relname=%.*s, \
|
||||
blockNum=%d, flags=0x%x, refcount=%d %d)\n",
|
||||
i, buf->freeNext, buf->freePrev, NAMEDATALEN, &(buf->sb_relname),
|
||||
i, buf->freeNext, buf->freePrev, NAMEDATALEN, buf->sb_relname,
|
||||
buf->tag.blockNum, buf->flags,
|
||||
buf->refcount, PrivateRefCount[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user