1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

Add more critical-section calls: all code sections that hold spinlocks

are now critical sections, so as to ensure die() won't interrupt us while
we are munging shared-memory data structures.  Avoid insecure intermediate
states in some code that proc_exit will call, like palloc/pfree.  Rename
START/END_CRIT_CODE to START/END_CRIT_SECTION, since that seems to be
what people tend to call them anyway, and make them be called with () like
a function call, in hopes of not confusing pg_indent.
I doubt that this is sufficient to make SIGTERM safe anywhere; there's
just too much code that could get invoked during proc_exit().
This commit is contained in:
Tom Lane
2001-01-12 21:54:01 +00:00
parent be8477bc37
commit 6162432de9
17 changed files with 163 additions and 129 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.45 2000/12/29 20:47:17 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.46 2001/01/12 21:53:55 tgl Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
@@ -165,7 +165,7 @@ _bt_getroot(Relation rel, int access)
rootpage = BufferGetPage(rootbuf);
/* NO ELOG(ERROR) till meta is updated */
START_CRIT_CODE;
START_CRIT_SECTION();
metad->btm_root = rootblkno;
metad->btm_level = 1;
@@ -197,7 +197,7 @@ _bt_getroot(Relation rel, int access)
PageSetSUI(metapg, ThisStartUpID);
}
END_CRIT_CODE;
END_CRIT_SECTION();
_bt_wrtnorelbuf(rel, rootbuf);
@@ -410,7 +410,7 @@ _bt_pagedel(Relation rel, ItemPointer tid)
buf = _bt_getbuf(rel, blkno, BT_WRITE);
page = BufferGetPage(buf);
START_CRIT_CODE;
START_CRIT_SECTION();
PageIndexTupleDelete(page, offno);
/* XLOG stuff */
{
@@ -435,7 +435,7 @@ _bt_pagedel(Relation rel, ItemPointer tid)
PageSetLSN(page, recptr);
PageSetSUI(page, ThisStartUpID);
}
END_CRIT_CODE;
END_CRIT_SECTION();
/* write the buffer and release the lock */
_bt_wrtbuf(rel, buf);