mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Ye-old pgindent run. Same 4-space tabs.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.45 2000/01/26 05:56:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.46 2000/04/12 17:15:36 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -49,7 +49,7 @@
|
||||
* so that an elog() from an on_proc_exit routine cannot get us out
|
||||
* of the exit procedure. We do NOT want to go back to the idle loop...
|
||||
*/
|
||||
bool proc_exit_inprogress = false;
|
||||
bool proc_exit_inprogress = false;
|
||||
|
||||
static int UsePrivateMemory = 0;
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef struct _PrivateMemStruct
|
||||
char *memptr;
|
||||
} PrivateMem;
|
||||
|
||||
static PrivateMem IpcPrivateMem[16];
|
||||
static PrivateMem IpcPrivateMem[16];
|
||||
|
||||
|
||||
static int
|
||||
@@ -117,6 +117,7 @@ PrivateMemoryAttach(IpcMemoryId memid)
|
||||
void
|
||||
proc_exit(int code)
|
||||
{
|
||||
|
||||
/*
|
||||
* Once we set this flag, we are committed to exit. Any elog() will
|
||||
* NOT send control back to the main loop, but right back here.
|
||||
@@ -140,7 +141,7 @@ proc_exit(int code)
|
||||
*/
|
||||
while (--on_proc_exit_index >= 0)
|
||||
(*on_proc_exit_list[on_proc_exit_index].function) (code,
|
||||
on_proc_exit_list[on_proc_exit_index].arg);
|
||||
on_proc_exit_list[on_proc_exit_index].arg);
|
||||
|
||||
TPRINTF(TRACE_VERBOSE, "exit(%d)", code);
|
||||
exit(code);
|
||||
@@ -166,7 +167,7 @@ shmem_exit(int code)
|
||||
*/
|
||||
while (--on_shmem_exit_index >= 0)
|
||||
(*on_shmem_exit_list[on_shmem_exit_index].function) (code,
|
||||
on_shmem_exit_list[on_shmem_exit_index].arg);
|
||||
on_shmem_exit_list[on_shmem_exit_index].arg);
|
||||
|
||||
on_shmem_exit_index = 0;
|
||||
}
|
||||
@@ -179,7 +180,7 @@ shmem_exit(int code)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
on_proc_exit(void (*function) (), caddr_t arg)
|
||||
on_proc_exit(void (*function) (), caddr_t arg)
|
||||
{
|
||||
if (on_proc_exit_index >= MAX_ON_EXITS)
|
||||
return -1;
|
||||
@@ -200,7 +201,7 @@ on_proc_exit(void (*function) (), caddr_t arg)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
on_shmem_exit(void (*function) (), caddr_t arg)
|
||||
on_shmem_exit(void (*function) (), caddr_t arg)
|
||||
{
|
||||
if (on_shmem_exit_index >= MAX_ON_EXITS)
|
||||
return -1;
|
||||
@@ -288,7 +289,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
|
||||
/* check arguments */
|
||||
if (semNum > IPC_NMAXSEM || semNum <= 0)
|
||||
return(-1);
|
||||
return (-1);
|
||||
|
||||
semId = semget(semKey, 0, 0);
|
||||
|
||||
@@ -308,7 +309,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
"key=%d, num=%d, permission=%o",
|
||||
strerror(errno), semKey, semNum, permission);
|
||||
IpcConfigTip();
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
for (i = 0; i < semNum; i++)
|
||||
array[i] = semStartValue;
|
||||
@@ -320,7 +321,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
strerror(errno), semId);
|
||||
semctl(semId, 0, IPC_RMID, semun);
|
||||
IpcConfigTip();
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (removeOnExit)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.32 2000/01/26 05:56:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.33 2000/04/12 17:15:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -56,14 +56,16 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
|
||||
{
|
||||
int size;
|
||||
extern int XLOGShmemSize(void);
|
||||
extern void XLOGShmemInit(void);
|
||||
extern void XLOGShmemInit(void);
|
||||
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
|
||||
/*
|
||||
* Create shared memory for slocks
|
||||
*/
|
||||
CreateAndInitSLockMemory(IPCKeyGetSLockSharedMemoryKey(key));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Kill and create the buffer manager buffer pool (and semaphore)
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.49 2000/02/26 05:25:55 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.50 2000/04/12 17:15:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -340,9 +340,9 @@ ShmemInitHash(char *name, /* table string name for shmem index */
|
||||
long *location;
|
||||
|
||||
/*
|
||||
* Hash tables allocated in shared memory have a fixed directory;
|
||||
* it can't grow or other backends wouldn't be able to find it.
|
||||
* So, make sure we make it big enough to start with.
|
||||
* Hash tables allocated in shared memory have a fixed directory; it
|
||||
* can't grow or other backends wouldn't be able to find it. So, make
|
||||
* sure we make it big enough to start with.
|
||||
*
|
||||
* The segbase is for calculating pointer values. The shared memory
|
||||
* allocator must be specified too.
|
||||
@@ -354,7 +354,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */
|
||||
|
||||
/* look it up in the shmem index */
|
||||
location = ShmemInitStruct(name,
|
||||
sizeof(HHDR) + infoP->dsize * sizeof(SEG_OFFSET),
|
||||
sizeof(HHDR) + infoP->dsize * sizeof(SEG_OFFSET),
|
||||
&found);
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.20 2000/01/26 05:56:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.21 2000/04/12 17:15:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -96,8 +96,8 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
||||
Index hashIndex,
|
||||
ItemPointer pointer)
|
||||
{
|
||||
SharedInvalidData newInvalid;
|
||||
bool insertOK;
|
||||
SharedInvalidData newInvalid;
|
||||
bool insertOK;
|
||||
|
||||
/*
|
||||
* This code has been hacked to accept two types of messages. This
|
||||
@@ -121,7 +121,7 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
||||
SpinAcquire(SInvalLock);
|
||||
insertOK = SIInsertDataEntry(shmInvalBuffer, &newInvalid);
|
||||
SpinRelease(SInvalLock);
|
||||
if (! insertOK)
|
||||
if (!insertOK)
|
||||
elog(NOTICE, "RegisterSharedInvalid: SI buffer overflow");
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
||||
* Process shared-cache-invalidation messages waiting for this backend
|
||||
*/
|
||||
void
|
||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
{
|
||||
SharedInvalidData data;
|
||||
int getResult;
|
||||
bool gotMessage = false;
|
||||
SharedInvalidData data;
|
||||
int getResult;
|
||||
bool gotMessage = false;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -171,13 +171,13 @@ InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Functions that need to scan the PROC structures of all running backends. */
|
||||
/* Functions that need to scan the PROC structures of all running backends. */
|
||||
/* It's a bit strange to keep these in sinval.c, since they don't have any */
|
||||
/* direct relationship to shared-cache invalidation. But the procState */
|
||||
/* array in the SI segment is the only place in the system where we have */
|
||||
/* an array of per-backend data, so it is the most convenient place to keep */
|
||||
/* an array of per-backend data, so it is the most convenient place to keep */
|
||||
/* pointers to the backends' PROC structures. We used to implement these */
|
||||
/* functions with a slow, ugly search through the ShmemIndex hash table --- */
|
||||
/* functions with a slow, ugly search through the ShmemIndex hash table --- */
|
||||
/* now they are simple loops over the SI ProcState array. */
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -205,7 +205,7 @@ DatabaseHasActiveBackends(Oid databaseId)
|
||||
|
||||
for (index = 0; index < segP->maxBackends; index++)
|
||||
{
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
|
||||
if (pOffset != INVALID_OFFSET)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ TransactionIdIsInProgress(TransactionId xid)
|
||||
|
||||
for (index = 0; index < segP->maxBackends; index++)
|
||||
{
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
|
||||
if (pOffset != INVALID_OFFSET)
|
||||
{
|
||||
@@ -277,14 +277,15 @@ GetXmaxRecent(TransactionId *XmaxRecent)
|
||||
|
||||
for (index = 0; index < segP->maxBackends; index++)
|
||||
{
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
|
||||
if (pOffset != INVALID_OFFSET)
|
||||
{
|
||||
PROC *proc = (PROC *) MAKE_PTR(pOffset);
|
||||
TransactionId xmin;
|
||||
|
||||
xmin = proc->xmin; /* we don't use spin-locking in AbortTransaction() ! */
|
||||
xmin = proc->xmin; /* we don't use spin-locking in
|
||||
* AbortTransaction() ! */
|
||||
if (proc == MyProc || xmin < FirstTransactionId)
|
||||
continue;
|
||||
if (xmin < *XmaxRecent)
|
||||
@@ -307,8 +308,9 @@ GetSnapshotData(bool serializable)
|
||||
int index;
|
||||
int count = 0;
|
||||
|
||||
/* There can be no more than maxBackends active transactions,
|
||||
* so this is enough space:
|
||||
/*
|
||||
* There can be no more than maxBackends active transactions, so this
|
||||
* is enough space:
|
||||
*/
|
||||
snapshot->xip = (TransactionId *)
|
||||
malloc(segP->maxBackends * sizeof(TransactionId));
|
||||
@@ -317,8 +319,8 @@ GetSnapshotData(bool serializable)
|
||||
SpinAcquire(SInvalLock);
|
||||
|
||||
/*
|
||||
* Unfortunately, we have to call ReadNewTransactionId()
|
||||
* after acquiring SInvalLock above. It's not good because
|
||||
* Unfortunately, we have to call ReadNewTransactionId() after
|
||||
* acquiring SInvalLock above. It's not good because
|
||||
* ReadNewTransactionId() does SpinAcquire(OidGenLockId) but
|
||||
* _necessary_.
|
||||
*/
|
||||
@@ -326,26 +328,27 @@ GetSnapshotData(bool serializable)
|
||||
|
||||
for (index = 0; index < segP->maxBackends; index++)
|
||||
{
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
SHMEM_OFFSET pOffset = stateP[index].procStruct;
|
||||
|
||||
if (pOffset != INVALID_OFFSET)
|
||||
{
|
||||
PROC *proc = (PROC *) MAKE_PTR(pOffset);
|
||||
TransactionId xid;
|
||||
|
||||
/*
|
||||
* We don't use spin-locking when changing proc->xid
|
||||
* in GetNewTransactionId() and in AbortTransaction() !..
|
||||
/*
|
||||
* We don't use spin-locking when changing proc->xid in
|
||||
* GetNewTransactionId() and in AbortTransaction() !..
|
||||
*/
|
||||
xid = proc->xid;
|
||||
if (proc == MyProc ||
|
||||
if (proc == MyProc ||
|
||||
xid < FirstTransactionId || xid >= snapshot->xmax)
|
||||
{
|
||||
|
||||
/*
|
||||
* Seems that there is no sense to store xid >= snapshot->xmax
|
||||
* (what we got from ReadNewTransactionId above) in
|
||||
* snapshot->xip - we just assume that all xacts with such
|
||||
* xid-s are running and may be ignored.
|
||||
* Seems that there is no sense to store xid >=
|
||||
* snapshot->xmax (what we got from ReadNewTransactionId
|
||||
* above) in snapshot->xip - we just assume that all xacts
|
||||
* with such xid-s are running and may be ignored.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.29 2000/03/17 02:36:21 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.30 2000/04/12 17:15:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -53,8 +53,9 @@ SISegmentInit(bool createNewSegment, IPCKey key, int maxBackends)
|
||||
/* Kill existing segment, if any */
|
||||
IpcMemoryKill(key);
|
||||
|
||||
/* Figure space needed.
|
||||
* Note sizeof(SISeg) includes the first ProcState entry.
|
||||
/*
|
||||
* Figure space needed. Note sizeof(SISeg) includes the first
|
||||
* ProcState entry.
|
||||
*/
|
||||
segSize = sizeof(SISeg) + sizeof(ProcState) * (maxBackends - 1);
|
||||
|
||||
@@ -125,7 +126,7 @@ SISegInit(SISeg *segP, int maxBackends)
|
||||
/* Mark all backends inactive */
|
||||
for (i = 0; i < maxBackends; i++)
|
||||
{
|
||||
segP->procState[i].nextMsgNum = -1; /* inactive */
|
||||
segP->procState[i].nextMsgNum = -1; /* inactive */
|
||||
segP->procState[i].resetState = false;
|
||||
segP->procState[i].tag = InvalidBackendTag;
|
||||
segP->procState[i].procStruct = INVALID_OFFSET;
|
||||
@@ -143,8 +144,8 @@ SISegInit(SISeg *segP, int maxBackends)
|
||||
int
|
||||
SIBackendInit(SISeg *segP)
|
||||
{
|
||||
int index;
|
||||
ProcState *stateP = NULL;
|
||||
int index;
|
||||
ProcState *stateP = NULL;
|
||||
|
||||
Assert(MyBackendTag > 0);
|
||||
|
||||
@@ -165,7 +166,8 @@ SIBackendInit(SISeg *segP)
|
||||
}
|
||||
}
|
||||
|
||||
/* elog() with spinlock held is probably not too cool, but this
|
||||
/*
|
||||
* elog() with spinlock held is probably not too cool, but this
|
||||
* condition should never happen anyway.
|
||||
*/
|
||||
if (stateP == NULL)
|
||||
@@ -230,11 +232,12 @@ CleanupInvalidationState(int status,
|
||||
bool
|
||||
SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
|
||||
{
|
||||
int numMsgs = segP->maxMsgNum - segP->minMsgNum;
|
||||
int numMsgs = segP->maxMsgNum - segP->minMsgNum;
|
||||
|
||||
/* Is the buffer full? */
|
||||
if (numMsgs >= MAXNUMMESSAGES)
|
||||
{
|
||||
|
||||
/*
|
||||
* Don't panic just yet: slowest backend might have consumed some
|
||||
* messages but not yet have done SIDelExpiredDataEntries() to
|
||||
@@ -254,8 +257,9 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
|
||||
* Try to prevent table overflow. When the table is 70% full send a
|
||||
* SIGUSR2 (ordinarily a NOTIFY signal) to the postmaster, which will
|
||||
* send it back to all the backends. This will force idle backends to
|
||||
* execute a transaction to look through pg_listener for NOTIFY messages,
|
||||
* and as a byproduct of the transaction start they will read SI entries.
|
||||
* execute a transaction to look through pg_listener for NOTIFY
|
||||
* messages, and as a byproduct of the transaction start they will
|
||||
* read SI entries.
|
||||
*
|
||||
* This should never happen if all the backends are actively executing
|
||||
* queries, but if a backend is sitting idle then it won't be starting
|
||||
@@ -267,7 +271,7 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
|
||||
IsUnderPostmaster)
|
||||
{
|
||||
TPRINTF(TRACE_VERBOSE,
|
||||
"SIInsertDataEntry: table is 70%% full, signaling postmaster");
|
||||
"SIInsertDataEntry: table is 70%% full, signaling postmaster");
|
||||
kill(getppid(), SIGUSR2);
|
||||
}
|
||||
|
||||
@@ -296,7 +300,7 @@ SISetProcStateInvalid(SISeg *segP)
|
||||
|
||||
for (i = 0; i < segP->maxBackends; i++)
|
||||
{
|
||||
if (segP->procState[i].nextMsgNum >= 0) /* active backend? */
|
||||
if (segP->procState[i].nextMsgNum >= 0) /* active backend? */
|
||||
{
|
||||
segP->procState[i].resetState = true;
|
||||
segP->procState[i].nextMsgNum = 0;
|
||||
@@ -318,13 +322,15 @@ int
|
||||
SIGetDataEntry(SISeg *segP, int backendId,
|
||||
SharedInvalidData *data)
|
||||
{
|
||||
ProcState *stateP = & segP->procState[backendId - 1];
|
||||
ProcState *stateP = &segP->procState[backendId - 1];
|
||||
|
||||
Assert(stateP->tag == MyBackendTag);
|
||||
|
||||
if (stateP->resetState)
|
||||
{
|
||||
/* Force reset. We can say we have dealt with any messages added
|
||||
|
||||
/*
|
||||
* Force reset. We can say we have dealt with any messages added
|
||||
* since the reset, as well...
|
||||
*/
|
||||
stateP->resetState = false;
|
||||
@@ -341,9 +347,10 @@ SIGetDataEntry(SISeg *segP, int backendId,
|
||||
*data = segP->buffer[stateP->nextMsgNum % MAXNUMMESSAGES];
|
||||
stateP->nextMsgNum++;
|
||||
|
||||
/* There may be other backends that haven't read the message,
|
||||
* so we cannot delete it here.
|
||||
* SIDelExpiredDataEntries() should be called to remove dead messages.
|
||||
/*
|
||||
* There may be other backends that haven't read the message, so we
|
||||
* cannot delete it here. SIDelExpiredDataEntries() should be called
|
||||
* to remove dead messages.
|
||||
*/
|
||||
return 1; /* got a message */
|
||||
}
|
||||
@@ -376,8 +383,9 @@ SIDelExpiredDataEntries(SISeg *segP)
|
||||
}
|
||||
segP->minMsgNum = min;
|
||||
|
||||
/* When minMsgNum gets really large, decrement all message counters
|
||||
* so as to forestall overflow of the counters.
|
||||
/*
|
||||
* When minMsgNum gets really large, decrement all message counters so
|
||||
* as to forestall overflow of the counters.
|
||||
*/
|
||||
if (min >= MSGNUMWRAPAROUND)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.23 2000/04/12 04:58:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.24 2000/04/12 17:15:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -59,7 +59,8 @@ InitSpinLocks(void)
|
||||
extern SPINLOCK SInvalLock;
|
||||
extern SPINLOCK OidGenLockId;
|
||||
extern SPINLOCK XidGenLockId;
|
||||
extern SPINLOCK ControlFileLockId;
|
||||
extern SPINLOCK ControlFileLockId;
|
||||
|
||||
#ifdef STABLE_MEMORY_STORAGE
|
||||
extern SPINLOCK MMCacheLock;
|
||||
|
||||
@@ -233,7 +234,7 @@ CreateSpinlocks(IPCKey key)
|
||||
{
|
||||
|
||||
SpinLockId = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
|
||||
IpcSemaphoreDefaultStartValue, 1);
|
||||
IpcSemaphoreDefaultStartValue, 1);
|
||||
|
||||
if (SpinLockId <= 0)
|
||||
elog(STOP, "CreateSpinlocks: cannot create spin locks");
|
||||
@@ -264,7 +265,7 @@ InitSpinLocks(void)
|
||||
extern SPINLOCK SInvalLock;
|
||||
extern SPINLOCK OidGenLockId;
|
||||
extern SPINLOCK XidGenLockId;
|
||||
extern SPINLOCK ControlFileLockId;
|
||||
extern SPINLOCK ControlFileLockId;
|
||||
|
||||
#ifdef STABLE_MEMORY_STORAGE
|
||||
extern SPINLOCK MMCacheLock;
|
||||
|
||||
Reference in New Issue
Block a user