summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2001-01-12 21:54:01 +0000
committerTom Lane2001-01-12 21:54:01 +0000
commit6162432de9fb023b710c171f196e27b910e45fa7 (patch)
tree51bba2e60ca2d3497b365b23edd52d52574faae2 /src/include
parentbe8477bc3718a05b02dd7e9f8236c16394f9a027 (diff)
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().
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/xlog.h4
-rw-r--r--src/include/utils/elog.h11
2 files changed, 7 insertions, 8 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 88268b0b0b2..7736ec92e87 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -3,7 +3,7 @@
*
* PostgreSQL transaction log manager
*
- * $Header: /cvsroot/pgsql/src/include/access/xlog.h,v 1.15 2000/12/28 13:00:25 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/include/access/xlog.h,v 1.16 2001/01/12 21:54:01 tgl Exp $
*/
#ifndef XLOG_H
#define XLOG_H
@@ -101,7 +101,7 @@ typedef XLogPageHeaderData *XLogPageHeader;
extern StartUpID ThisStartUpID; /* current SUI */
extern bool InRecovery;
extern XLogRecPtr MyLastRecPtr;
-extern uint32 CritSectionCount;
+extern volatile uint32 CritSectionCount;
typedef struct RmgrData
{
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index e7305d67fc2..da9178b2767 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: elog.h,v 1.22 2001/01/07 04:17:28 tgl Exp $
+ * $Id: elog.h,v 1.23 2001/01/12 21:54:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,16 +34,15 @@ extern int Use_syslog;
* ProcDiePending will be honored at critical section exit,
* but QueryCancel is only checked at specified points.
*/
-extern uint32 CritSectionCount; /* duplicates access/xlog.h */
+extern volatile uint32 CritSectionCount; /* duplicates access/xlog.h */
extern volatile bool ProcDiePending;
extern void ForceProcDie(void); /* in postgres.c */
-#define START_CRIT_CODE (CritSectionCount++)
+#define START_CRIT_SECTION() (CritSectionCount++)
-#define END_CRIT_CODE \
+#define END_CRIT_SECTION() \
do { \
- if (CritSectionCount == 0) \
- elog(STOP, "Not in critical section"); \
+ Assert(CritSectionCount > 0); \
CritSectionCount--; \
if (CritSectionCount == 0 && ProcDiePending) \
ForceProcDie(); \