@ -290,13 +290,6 @@ InitProcess(void)
if ( MyProc ! = NULL )
if ( MyProc ! = NULL )
elog ( ERROR , " you already exist " ) ;
elog ( ERROR , " you already exist " ) ;
/*
* Initialize process - local latch support . This could fail if the kernel
* is low on resources , and if so we want to exit cleanly before acquiring
* any shared - memory resources .
*/
InitializeLatchSupport ( ) ;
/*
/*
* Try to get a proc struct from the free list . If this fails , we must be
* Try to get a proc struct from the free list . If this fails , we must be
* out of PGPROC structures ( not to mention semaphores ) .
* out of PGPROC structures ( not to mention semaphores ) .
@ -391,10 +384,12 @@ InitProcess(void)
SHMQueueElemInit ( & ( MyProc - > syncRepLinks ) ) ;
SHMQueueElemInit ( & ( MyProc - > syncRepLinks ) ) ;
/*
/*
* Acquire ownership of the PGPROC ' s latch , so that we can use WaitLatch .
* Acquire ownership of the PGPROC ' s latch , so that we can use WaitLatch
* Note that there ' s no particular need to do ResetLatch here .
* on it . That allows us to repoint the process latch , which so far
* points to process local one , to the shared one .
*/
*/
OwnLatch ( & MyProc - > procLatch ) ;
OwnLatch ( & MyProc - > procLatch ) ;
SwitchToSharedLatch ( ) ;
/*
/*
* We might be reusing a semaphore that belonged to a failed process . So
* We might be reusing a semaphore that belonged to a failed process . So
@ -474,13 +469,6 @@ InitAuxiliaryProcess(void)
if ( MyProc ! = NULL )
if ( MyProc ! = NULL )
elog ( ERROR , " you already exist " ) ;
elog ( ERROR , " you already exist " ) ;
/*
* Initialize process - local latch support . This could fail if the kernel
* is low on resources , and if so we want to exit cleanly before acquiring
* any shared - memory resources .
*/
InitializeLatchSupport ( ) ;
/*
/*
* We use the ProcStructLock to protect assignment and releasing of
* We use the ProcStructLock to protect assignment and releasing of
* AuxiliaryProcs entries .
* AuxiliaryProcs entries .
@ -547,10 +535,12 @@ InitAuxiliaryProcess(void)
# endif
# endif
/*
/*
* Acquire ownership of the PGPROC ' s latch , so that we can use WaitLatch .
* Acquire ownership of the PGPROC ' s latch , so that we can use WaitLatch
* Note that there ' s no particular need to do ResetLatch here .
* on it . That allows us to repoint the process latch , which so far
* points to process local one , to the shared one .
*/
*/
OwnLatch ( & MyProc - > procLatch ) ;
OwnLatch ( & MyProc - > procLatch ) ;
SwitchToSharedLatch ( ) ;
/*
/*
* We might be reusing a semaphore that belonged to a failed process . So
* We might be reusing a semaphore that belonged to a failed process . So
@ -800,10 +790,12 @@ ProcKill(int code, Datum arg)
ReplicationSlotRelease ( ) ;
ReplicationSlotRelease ( ) ;
/*
/*
* Clear MyProc first ; then disown the process latch . This is so that
* Reset MyLatch to the process local one . This is so that signal
* signal handlers won ' t try to clear the process latch after it ' s no
* handlers et al can continue using the latch after the shared latch
* longer ours .
* isn ' t ours anymore . After that clear MyProc and disown the shared
* latch .
*/
*/
SwitchBackToLocalLatch ( ) ;
proc = MyProc ;
proc = MyProc ;
MyProc = NULL ;
MyProc = NULL ;
DisownLatch ( & proc - > procLatch ) ;
DisownLatch ( & proc - > procLatch ) ;
@ -867,10 +859,12 @@ AuxiliaryProcKill(int code, Datum arg)
LWLockReleaseAll ( ) ;
LWLockReleaseAll ( ) ;
/*
/*
* Clear MyProc first ; then disown the process latch . This is so that
* Reset MyLatch to the process local one . This is so that signal
* signal handlers won ' t try to clear the process latch after it ' s no
* handlers et al can continue using the latch after the shared latch
* longer ours .
* isn ' t ours anymore . After that clear MyProc and disown the shared
* latch .
*/
*/
SwitchBackToLocalLatch ( ) ;
proc = MyProc ;
proc = MyProc ;
MyProc = NULL ;
MyProc = NULL ;
DisownLatch ( & proc - > procLatch ) ;
DisownLatch ( & proc - > procLatch ) ;