88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.75 2008/12/0914:28:20 heikki Exp $
11+ * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.76 2008/12/0915:59:39 heikki Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2121#include "storage/backendid.h"
2222#include "storage/ipc.h"
2323#include "storage/proc.h"
24- #include "storage/procarray.h"
2524#include "storage/shmem.h"
2625#include "storage/sinvaladt.h"
2726#include "storage/spin.h"
137136/* Per-backend state in shared invalidation structure */
138137typedef struct ProcState
139138{
140- /*proc isNULL in an inactive ProcState array entry. */
141- PGPROC * proc ;/*PGPROC entry of backend, for signaling */
142- /* nextMsgNum is meaningless ifproc ==NULL or resetState is true. */
139+ /*procPid iszero in an inactive ProcState array entry. */
140+ pid_t procPid ;/*PID of backend, for signaling */
141+ /* nextMsgNum is meaningless ifprocPid ==0 or resetState is true. */
143142int nextMsgNum ;/* next message number to read */
144143bool resetState ;/* backend needs to reset its state */
145144bool signaled ;/* backend has been sent catchup signal */
@@ -236,7 +235,7 @@ CreateSharedInvalidationState(void)
236235/* Mark all backends inactive, and initialize nextLXID */
237236for (i = 0 ;i < shmInvalBuffer -> maxBackends ;i ++ )
238237{
239- shmInvalBuffer -> procState [i ].proc = NULL ;/* inactive */
238+ shmInvalBuffer -> procState [i ].procPid = 0 ;/* inactive */
240239shmInvalBuffer -> procState [i ].nextMsgNum = 0 ;/* meaningless */
241240shmInvalBuffer -> procState [i ].resetState = false;
242241shmInvalBuffer -> procState [i ].signaled = false;
@@ -267,7 +266,7 @@ SharedInvalBackendInit(void)
267266/* Look for a free entry in the procState array */
268267for (index = 0 ;index < segP -> lastBackend ;index ++ )
269268{
270- if (segP -> procState [index ].proc == NULL )/* inactive slot? */
269+ if (segP -> procState [index ].procPid == 0 )/* inactive slot? */
271270{
272271stateP = & segP -> procState [index ];
273272break ;
@@ -279,7 +278,7 @@ SharedInvalBackendInit(void)
279278if (segP -> lastBackend < segP -> maxBackends )
280279{
281280stateP = & segP -> procState [segP -> lastBackend ];
282- Assert (stateP -> proc == NULL );
281+ Assert (stateP -> procPid == 0 );
283282segP -> lastBackend ++ ;
284283}
285284else
@@ -304,7 +303,7 @@ SharedInvalBackendInit(void)
304303nextLocalTransactionId = stateP -> nextLXID ;
305304
306305/* mark myself active, with all extant messages already read */
307- stateP -> proc = MyProc ;
306+ stateP -> procPid = MyProcPid ;
308307stateP -> nextMsgNum = segP -> maxMsgNum ;
309308stateP -> resetState = false;
310309stateP -> signaled = false;
@@ -342,15 +341,15 @@ CleanupInvalidationState(int status, Datum arg)
342341stateP -> nextLXID = nextLocalTransactionId ;
343342
344343/* Mark myself inactive */
345- stateP -> proc = NULL ;
344+ stateP -> procPid = 0 ;
346345stateP -> nextMsgNum = 0 ;
347346stateP -> resetState = false;
348347stateP -> signaled = false;
349348
350349/* Recompute index of last active backend */
351350for (i = segP -> lastBackend ;i > 0 ;i -- )
352351{
353- if (segP -> procState [i - 1 ].proc != NULL )
352+ if (segP -> procState [i - 1 ].procPid != 0 )
354353break ;
355354}
356355segP -> lastBackend = i ;
@@ -375,7 +374,7 @@ BackendIdIsActive(int backendID)
375374{
376375ProcState * stateP = & segP -> procState [backendID - 1 ];
377376
378- result = (stateP -> proc != NULL );
377+ result = (stateP -> procPid != 0 );
379378}
380379else
381380result = false;
@@ -591,7 +590,7 @@ SICleanupQueue(bool callerHasWriteLock, int minFree)
591590int n = stateP -> nextMsgNum ;
592591
593592/* Ignore if inactive or already in reset state */
594- if (stateP -> proc == NULL || stateP -> resetState )
593+ if (stateP -> procPid == 0 || stateP -> resetState )
595594continue ;
596595
597596/*
@@ -645,20 +644,18 @@ SICleanupQueue(bool callerHasWriteLock, int minFree)
645644segP -> nextThreshold = (numMsgs /CLEANUP_QUANTUM + 1 )* CLEANUP_QUANTUM ;
646645
647646/*
648- * Lastly, signal anyone who needs a catchup interrupt. Since
649- * SendProcSignal() might not be fast, we don't want to hold locks while
650- * executing it.
647+ * Lastly, signal anyone who needs a catchup interrupt. Since kill()
648+ * might not be fast, we don't want to hold locks while executing it.
651649 */
652650if (needSig )
653651{
654- PGPROC * his_proc = needSig -> proc ;
652+ pid_t his_pid = needSig -> procPid ;
655653
656654needSig -> signaled = true;
657655LWLockRelease (SInvalReadLock );
658656LWLockRelease (SInvalWriteLock );
659- elog (DEBUG4 ,"sending sinval catchup signal to PID %d" ,
660- (int )his_proc -> pid );
661- SendProcSignal (his_proc ,PROCSIG_CATCHUP_INTERRUPT );
657+ elog (DEBUG4 ,"sending sinval catchup signal to PID %d" , (int )his_pid );
658+ kill (his_pid ,SIGUSR1 );
662659if (callerHasWriteLock )
663660LWLockAcquire (SInvalWriteLock ,LW_EXCLUSIVE );
664661}