mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +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:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.90 2001/01/09 09:38:57 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.91 2001/01/12 21:53:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,7 +48,7 @@
|
||||
* This is so that we can support more backends. (system-wide semaphore
|
||||
* sets run out pretty fast.) -ay 4/95
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.90 2001/01/09 09:38:57 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.91 2001/01/12 21:53:59 tgl Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
@ -241,7 +241,6 @@ InitProcess(void)
|
||||
MemSet(MyProc->sLocks, 0, sizeof(MyProc->sLocks));
|
||||
MyProc->sLocks[ProcStructLock] = 1;
|
||||
|
||||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
IpcSemaphoreId semId;
|
||||
@ -264,23 +263,16 @@ InitProcess(void)
|
||||
else
|
||||
MyProc->sem.semId = -1;
|
||||
|
||||
/* ----------------------
|
||||
* Release the lock.
|
||||
* ----------------------
|
||||
*/
|
||||
SpinRelease(ProcStructLock);
|
||||
|
||||
MyProc->pid = MyProcPid;
|
||||
MyProc->databaseId = MyDatabaseId;
|
||||
MyProc->xid = InvalidTransactionId;
|
||||
MyProc->xmin = InvalidTransactionId;
|
||||
|
||||
/* ----------------
|
||||
* Start keeping spin lock stats from here on. Any botch before
|
||||
* this initialization is forever botched
|
||||
* ----------------
|
||||
/* ----------------------
|
||||
* Release the lock.
|
||||
* ----------------------
|
||||
*/
|
||||
MemSet(MyProc->sLocks, 0, MAX_SPINS * sizeof(*MyProc->sLocks));
|
||||
SpinRelease(ProcStructLock);
|
||||
|
||||
/* -------------------------
|
||||
* Install ourselves in the shmem index table. The name to
|
||||
@ -412,15 +404,6 @@ ProcKill(int exitStatus, Datum pid)
|
||||
{
|
||||
PROC *proc;
|
||||
|
||||
/* --------------------
|
||||
* If this is a FATAL exit the postmaster will have to kill all the
|
||||
* existing backends and reinitialize shared memory. So we don't
|
||||
* need to do anything here.
|
||||
* --------------------
|
||||
*/
|
||||
if (exitStatus != 0)
|
||||
return;
|
||||
|
||||
if ((int) pid == MyProcPid)
|
||||
{
|
||||
proc = MyProc;
|
||||
|
Reference in New Issue
Block a user