mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
OK, folks, here is the pgindent output.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.32 1998/09/01 03:25:08 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.33 1998/09/01 04:31:47 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <sys/ipc.h>
|
||||
#endif
|
||||
|
||||
static int UsePrivateMemory = 0;
|
||||
static int UsePrivateMemory = 0;
|
||||
|
||||
static void IpcMemoryDetach(int status, char *shmaddr);
|
||||
|
||||
@@ -61,9 +61,10 @@ static struct ONEXIT
|
||||
{
|
||||
void (*function) ();
|
||||
caddr_t arg;
|
||||
} on_proc_exit_list[MAX_ON_EXITS], on_shmem_exit_list[MAX_ON_EXITS];
|
||||
} on_proc_exit_list[MAX_ON_EXITS], on_shmem_exit_list[MAX_ON_EXITS];
|
||||
|
||||
static int on_proc_exit_index, on_shmem_exit_index;
|
||||
static int on_proc_exit_index,
|
||||
on_shmem_exit_index;
|
||||
static void IpcConfigTip(void);
|
||||
|
||||
typedef struct _PrivateMemStruct
|
||||
@@ -116,11 +117,12 @@ proc_exit(int code)
|
||||
|
||||
TPRINTF(TRACE_VERBOSE, "proc_exit(%d) [#%d]", code, proc_exit_inprogress);
|
||||
|
||||
/*
|
||||
* If proc_exit is called too many times something bad is
|
||||
* happenig, so exit immediately.
|
||||
/*
|
||||
* If proc_exit is called too many times something bad is happenig, so
|
||||
* exit immediately.
|
||||
*/
|
||||
if (proc_exit_inprogress > 9) {
|
||||
if (proc_exit_inprogress > 9)
|
||||
{
|
||||
elog(ERROR, "infinite recursion in proc_exit");
|
||||
goto exit;
|
||||
}
|
||||
@@ -136,7 +138,7 @@ proc_exit(int code)
|
||||
|
||||
/* do our shared memory exits first */
|
||||
shmem_exit(code);
|
||||
|
||||
|
||||
/* ----------------
|
||||
* call all the callbacks registered before calling exit().
|
||||
* ----------------
|
||||
@@ -166,10 +168,11 @@ shmem_exit(int code)
|
||||
code, shmem_exit_inprogress);
|
||||
|
||||
/*
|
||||
* If shmem_exit is called too many times something bad is
|
||||
* happenig, so exit immediately.
|
||||
* If shmem_exit is called too many times something bad is happenig,
|
||||
* so exit immediately.
|
||||
*/
|
||||
if (shmem_exit_inprogress > 9) {
|
||||
if (shmem_exit_inprogress > 9)
|
||||
{
|
||||
elog(ERROR, "infinite recursion in shmem_exit");
|
||||
exit(-1);
|
||||
}
|
||||
@@ -202,7 +205,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;
|
||||
@@ -223,7 +226,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;
|
||||
@@ -402,7 +405,7 @@ IpcSemaphoreSet(int semId, int semno, int value)
|
||||
|
||||
if (errStatus == -1)
|
||||
{
|
||||
EPRINTF("IpcSemaphoreSet: semctl failed (%s) id=%d",
|
||||
EPRINTF("IpcSemaphoreSet: semctl failed (%s) id=%d",
|
||||
strerror(errno), semId);
|
||||
}
|
||||
}
|
||||
@@ -734,7 +737,7 @@ LockIsFree(int lockid)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
|
||||
static void
|
||||
IpcConfigTip(void)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.30 1998/09/01 03:25:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.31 1998/09/01 04:31:49 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ unsigned long ShmemBase = 0; /* start and end address of shared memory */
|
||||
static unsigned long ShmemEnd = 0;
|
||||
static unsigned long ShmemSize = 0; /* current size (and default) */
|
||||
|
||||
extern VariableCache ShmemVariableCache; /* varsup.c */
|
||||
extern VariableCache ShmemVariableCache; /* varsup.c */
|
||||
|
||||
SPINLOCK ShmemLock; /* lock for shared memory allocation */
|
||||
|
||||
@@ -85,8 +85,9 @@ SPINLOCK ShmemIndexLock; /* lock for shmem index access */
|
||||
static unsigned long *ShmemFreeStart = NULL; /* pointer to the OFFSET
|
||||
* of first free shared
|
||||
* memory */
|
||||
static unsigned long *ShmemIndexOffset = NULL; /* start of the shmem index
|
||||
* table (for bootstrap) */
|
||||
static unsigned long *ShmemIndexOffset = NULL; /* start of the shmem
|
||||
* index table (for
|
||||
* bootstrap) */
|
||||
static int ShmemBootstrap = FALSE; /* flag becomes true when shared
|
||||
* mem is created by POSTMASTER */
|
||||
|
||||
@@ -155,6 +156,7 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
item;
|
||||
bool found;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
/* if zero key, use default memory size */
|
||||
if (size)
|
||||
ShmemSize = size;
|
||||
@@ -204,7 +206,7 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
if (ShmemBootstrap)
|
||||
{
|
||||
*ShmemFreeStart = currFreeSpace;
|
||||
memset (ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
|
||||
memset(ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
|
||||
}
|
||||
|
||||
/* if ShmemFreeStart is NULL, then the allocator won't work */
|
||||
@@ -217,8 +219,8 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
|
||||
/* This will acquire the shmem index lock, but not release it. */
|
||||
ShmemIndex = ShmemInitHash("ShmemIndex",
|
||||
SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
|
||||
&info, hash_flags);
|
||||
SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
|
||||
&info, hash_flags);
|
||||
|
||||
if (!ShmemIndex)
|
||||
{
|
||||
@@ -248,8 +250,7 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
{
|
||||
|
||||
/*
|
||||
* bootstrapping shmem: we have to initialize the shmem index
|
||||
* now.
|
||||
* bootstrapping shmem: we have to initialize the shmem index now.
|
||||
*/
|
||||
|
||||
Assert(ShmemBootstrap);
|
||||
@@ -501,14 +502,16 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr)
|
||||
{
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
char *strname = "ShmemIndex";
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the shmem index doesnt exist, we fake it.
|
||||
*
|
||||
* If we are creating the first shmem index, then let shmemalloc()
|
||||
* allocate the space for a new HTAB. Otherwise, find the old one
|
||||
* and return that. Notice that the ShmemIndexLock is held until the
|
||||
* shmem index has been completely initialized.
|
||||
* and return that. Notice that the ShmemIndexLock is held until
|
||||
* the shmem index has been completely initialized.
|
||||
*/
|
||||
Assert(!strcmp(name, strname));
|
||||
if (ShmemBootstrap)
|
||||
@@ -545,6 +548,7 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr)
|
||||
}
|
||||
else if (*foundPtr)
|
||||
{
|
||||
|
||||
/*
|
||||
* Structure is in the shmem index so someone else has allocated
|
||||
* it already. The size better be the same as the size we are
|
||||
@@ -634,23 +638,23 @@ TransactionIdIsInProgress(TransactionId xid)
|
||||
* placed in array. Current xact ID are never placed there (just
|
||||
* to reduce its length, xmin/xmax may be equal to cid).
|
||||
* MyProc->xmin will be setted if equal to InvalidTransactionId.
|
||||
*
|
||||
*
|
||||
* Yet another strange func for this place... - vadim 07/21/98
|
||||
*/
|
||||
Snapshot
|
||||
GetSnapshotData(bool serialized)
|
||||
{
|
||||
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
|
||||
TransactionId snapshot->xip = (TransactionId*)
|
||||
malloc(32 * sizeof(TransactionId));
|
||||
ShmemIndexEnt *result;
|
||||
PROC *proc;
|
||||
TransactionId cid = GetCurrentTransactionId();
|
||||
uint count = 0;
|
||||
unit free = 31;
|
||||
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
|
||||
TransactionId snapshot->xip = (TransactionId *)
|
||||
malloc(32 * sizeof(TransactionId));
|
||||
ShmemIndexEnt *result;
|
||||
PROC *proc;
|
||||
TransactionId cid = GetCurrentTransactionId();
|
||||
uint count = 0;
|
||||
unit free = 31;
|
||||
|
||||
Assert(ShmemIndex);
|
||||
|
||||
|
||||
snapshot->xmax = cid;
|
||||
snapshot->xmin = cid;
|
||||
|
||||
@@ -672,7 +676,7 @@ GetSnapshotData(bool serialized)
|
||||
continue;
|
||||
proc = (PROC *) MAKE_PTR(result->location);
|
||||
if (proc == MyProc || proc->xid < FirstTransactionId ||
|
||||
serialized && proc->xid >= cid)
|
||||
serialized && proc->xid >= cid)
|
||||
continue;
|
||||
if (proc->xid < snapshot->xmin)
|
||||
snapshot->xmin = proc->xid;
|
||||
@@ -680,8 +684,8 @@ GetSnapshotData(bool serialized)
|
||||
snapshot->xmax = proc->xid;
|
||||
if (free == 0)
|
||||
{
|
||||
snapshot->xip = (TransactionId*) realloc(snapshot->xip,
|
||||
(count + 33) * sizeof(TransactionId));
|
||||
snapshot->xip = (TransactionId *) realloc(snapshot->xip,
|
||||
(count + 33) * sizeof(TransactionId));
|
||||
free = 32;
|
||||
}
|
||||
snapshot->xip[count] = proc->xid;
|
||||
@@ -695,4 +699,5 @@ GetSnapshotData(bool serialized)
|
||||
elog(ERROR, "GetSnapshotData: ShmemIndex corrupted");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.8 1998/09/01 03:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.9 1998/09/01 04:31:50 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -32,7 +32,7 @@
|
||||
#define SHMQUEUE_DEBUG_HD /* head inserts */
|
||||
#define SHMQUEUE_DEBUG_TL /* tail inserts */
|
||||
#define SHMQUEUE_DEBUG_ELOG NOTICE
|
||||
#endif /* SHMQUEUE_DEBUG */
|
||||
#endif /* SHMQUEUE_DEBUG */
|
||||
|
||||
/*
|
||||
* ShmemQueueInit -- make the head of a new queue point
|
||||
@@ -85,14 +85,14 @@ SHMQueueDelete(SHM_QUEUE *queue)
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_DEL
|
||||
dumpQ(queue, "in SHMQueueDelete: begin");
|
||||
#endif /* SHMQUEUE_DEBUG_DEL */
|
||||
#endif /* SHMQUEUE_DEBUG_DEL */
|
||||
|
||||
prevElem->next = (queue)->next;
|
||||
nextElem->prev = (queue)->prev;
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_DEL
|
||||
dumpQ((SHM_QUEUE *) MAKE_PTR(queue->prev), "in SHMQueueDelete: end");
|
||||
#endif /* SHMQUEUE_DEBUG_DEL */
|
||||
#endif /* SHMQUEUE_DEBUG_DEL */
|
||||
}
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG
|
||||
@@ -144,7 +144,7 @@ dumpQ(SHM_QUEUE *q, char *s)
|
||||
elog(SHMQUEUE_DEBUG_ELOG, "%s: %s", s, buf);
|
||||
}
|
||||
|
||||
#endif /* SHMQUEUE_DEBUG */
|
||||
#endif /* SHMQUEUE_DEBUG */
|
||||
|
||||
/*
|
||||
* SHMQueueInsertHD -- put elem in queue between the queue head
|
||||
@@ -162,7 +162,7 @@ SHMQueueInsertHD(SHM_QUEUE *queue, SHM_QUEUE *elem)
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_HD
|
||||
dumpQ(queue, "in SHMQueueInsertHD: begin");
|
||||
#endif /* SHMQUEUE_DEBUG_HD */
|
||||
#endif /* SHMQUEUE_DEBUG_HD */
|
||||
|
||||
(elem)->next = prevPtr->next;
|
||||
(elem)->prev = queue->prev;
|
||||
@@ -171,7 +171,7 @@ SHMQueueInsertHD(SHM_QUEUE *queue, SHM_QUEUE *elem)
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_HD
|
||||
dumpQ(queue, "in SHMQueueInsertHD: end");
|
||||
#endif /* SHMQUEUE_DEBUG_HD */
|
||||
#endif /* SHMQUEUE_DEBUG_HD */
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -187,7 +187,7 @@ SHMQueueInsertTL(SHM_QUEUE *queue, SHM_QUEUE *elem)
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_TL
|
||||
dumpQ(queue, "in SHMQueueInsertTL: begin");
|
||||
#endif /* SHMQUEUE_DEBUG_TL */
|
||||
#endif /* SHMQUEUE_DEBUG_TL */
|
||||
|
||||
(elem)->prev = nextPtr->prev;
|
||||
(elem)->next = queue->next;
|
||||
@@ -196,7 +196,7 @@ SHMQueueInsertTL(SHM_QUEUE *queue, SHM_QUEUE *elem)
|
||||
|
||||
#ifdef SHMQUEUE_DEBUG_TL
|
||||
dumpQ(queue, "in SHMQueueInsertTL: end");
|
||||
#endif /* SHMQUEUE_DEBUG_TL */
|
||||
#endif /* SHMQUEUE_DEBUG_TL */
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.11 1998/08/25 21:31:17 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.12 1998/09/01 04:31:52 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -157,7 +157,8 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
||||
/* should be called by a backend */
|
||||
/****************************************************************************/
|
||||
void
|
||||
InvalidateSharedInvalid(void (*invalFunction) (), void (*resetFunction) ())
|
||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
{
|
||||
SpinAcquire(SInvalLock);
|
||||
SIReadEntryData(shmInvalBuffer, MyBackendId,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.14 1998/09/01 03:25:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.15 1998/09/01 04:31:53 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ SISetActiveProcess(SISeg *segInOutP, BackendId backendId)
|
||||
int
|
||||
SIBackendInit(SISeg *segInOutP)
|
||||
{
|
||||
LockRelId LtCreateRelId();
|
||||
LockRelId LtCreateRelId();
|
||||
TransactionId LMITransactionIdCopy();
|
||||
|
||||
Assert(MyBackendTag > 0);
|
||||
@@ -100,7 +100,7 @@ SIBackendInit(SISeg *segInOutP)
|
||||
#ifdef INVALIDDEBUG
|
||||
elog(DEBUG, "SIBackendInit: backend tag %d; backend id %d.",
|
||||
MyBackendTag, MyBackendId);
|
||||
#endif /* INVALIDDEBUG */
|
||||
#endif /* INVALIDDEBUG */
|
||||
|
||||
SISetActiveProcess(segInOutP, MyBackendId);
|
||||
on_shmem_exit(CleanupInvalidationState, (caddr_t) segInOutP);
|
||||
@@ -151,7 +151,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag)
|
||||
}
|
||||
|
||||
Assert(stateP);
|
||||
|
||||
|
||||
if (stateP->tag != InvalidBackendTag)
|
||||
{
|
||||
if (stateP->tag == backendTag)
|
||||
@@ -360,16 +360,18 @@ SIGetProcStateLimit(SISeg *segP, int i)
|
||||
static bool
|
||||
SIIncNumEntries(SISeg *segP, int num)
|
||||
{
|
||||
|
||||
/*
|
||||
* Try to prevent table overflow. When the table is 70% full send
|
||||
* a SIGUSR2 to the postmaster which will send it back to all the
|
||||
* Try to prevent table overflow. When the table is 70% full send a
|
||||
* SIGUSR2 to the postmaster which will send it back to all the
|
||||
* backends. This will be handled by Async_NotifyHandler() with a
|
||||
* StartTransactionCommand() which will flush unread SI entries for
|
||||
* each backend. dz - 27 Jan 1998
|
||||
*/
|
||||
if (segP->numEntries == (MAXNUMMESSAGES * 70 / 100)) {
|
||||
if (segP->numEntries == (MAXNUMMESSAGES * 70 / 100))
|
||||
{
|
||||
TPRINTF(TRACE_VERBOSE,
|
||||
"SIIncNumEntries: table is 70%% full, signaling postmaster");
|
||||
"SIIncNumEntries: table is 70%% full, signaling postmaster");
|
||||
kill(getppid(), SIGUSR2);
|
||||
}
|
||||
|
||||
@@ -844,7 +846,7 @@ SISegmentInit(bool killExistingSegment, IPCKey key)
|
||||
if (shmId < 0)
|
||||
{
|
||||
perror("SISegmentGet: failed");
|
||||
return -1; /* an error */
|
||||
return -1; /* an error */
|
||||
}
|
||||
|
||||
/* Attach the shared cache invalidation segment */
|
||||
@@ -862,7 +864,7 @@ SISegmentInit(bool killExistingSegment, IPCKey key)
|
||||
if (shmId < 0)
|
||||
{
|
||||
perror("SISegmentGet: getting an existent segment failed");
|
||||
return -1; /* an error */
|
||||
return -1; /* an error */
|
||||
}
|
||||
/* Attach the shared cache invalidation segment */
|
||||
SISegmentAttach(shmId);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.16 1998/09/01 03:25:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.17 1998/09/01 04:31:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -63,6 +63,7 @@ InitSpinLocks(int init, IPCKey key)
|
||||
|
||||
#ifdef STABLE_MEMORY_STORAGE
|
||||
extern SPINLOCK MMCacheLock;
|
||||
|
||||
#endif
|
||||
|
||||
/* These six spinlocks have fixed location is shmem */
|
||||
@@ -83,7 +84,7 @@ InitSpinLocks(int init, IPCKey key)
|
||||
|
||||
#ifdef LOCKDEBUG
|
||||
#define PRINT_LOCK(LOCK) \
|
||||
TPRINTF(TRACE_SPINLOCKS, \
|
||||
TPRINTF(TRACE_SPINLOCKS, \
|
||||
"(locklock = %d, flag = %d, nshlocks = %d, shlock = %d, " \
|
||||
"exlock =%d)\n", LOCK->locklock, \
|
||||
LOCK->flag, LOCK->nshlocks, LOCK->shlock, \
|
||||
@@ -140,9 +141,10 @@ SpinRelease(SPINLOCK lockid)
|
||||
slckP = &(SLockArray[lockid]);
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
|
||||
/*
|
||||
* Check that we are actually holding the lock we are releasing.
|
||||
* This can be done only after MyProc has been initialized.
|
||||
* Check that we are actually holding the lock we are releasing. This
|
||||
* can be done only after MyProc has been initialized.
|
||||
*/
|
||||
if (MyProc)
|
||||
Assert(MyProc->sLocks[lockid] > 0);
|
||||
@@ -334,4 +336,4 @@ InitSpinLocks(int init, IPCKey key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
|
||||
Reference in New Issue
Block a user