1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-03 09:13:20 +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

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.72 2000/12/29 20:47:16 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.73 2001/01/12 21:53:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -518,7 +518,7 @@ _bt_insertonpg(Relation rel,
}
else
{
START_CRIT_CODE;
START_CRIT_SECTION();
_bt_pgaddtup(rel, page, itemsz, btitem, newitemoff, "page");
itup_off = newitemoff;
itup_blkno = BufferGetBlockNumber(buf);
@@ -563,7 +563,7 @@ _bt_insertonpg(Relation rel,
PageSetSUI(page, ThisStartUpID);
}
END_CRIT_CODE;
END_CRIT_SECTION();
/* Write out the updated page and release pin/lock */
_bt_wrtbuf(rel, buf);
}
@@ -774,7 +774,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
* NO ELOG(ERROR) till right sibling is updated.
*
*/
START_CRIT_CODE;
START_CRIT_SECTION();
{
xl_btree_split xlrec;
int flag = (newitemonleft) ?
@@ -863,7 +863,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
/* write and release the old right sibling */
if (!P_RIGHTMOST(ropaque))
_bt_wrtbuf(rel, sbuf);
END_CRIT_CODE;
END_CRIT_SECTION();
/* split's done */
return rbuf;
@@ -1160,7 +1160,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
metad = BTPageGetMeta(metapg);
/* NO ELOG(ERROR) from here till newroot op is logged */
START_CRIT_CODE;
START_CRIT_SECTION();
/* set btree special data */
rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage);
@@ -1253,7 +1253,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
PageSetSUI(metapg, ThisStartUpID);
}
END_CRIT_CODE;
END_CRIT_SECTION();
/* write and let go of the new root buffer */
_bt_wrtbuf(rel, rootbuf);