mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pgindent run.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: bsdi.h,v 1.16 2002/06/20 20:29:33 momjian Exp $
|
||||
* $Id: bsdi.h,v 1.17 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -46,7 +46,6 @@ do { \
|
||||
dld_unlink_by_file(handle, 1); \
|
||||
free(handle); \
|
||||
} while (0)
|
||||
|
||||
#endif /* not HAVE_DLOPEN */
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.4 2002/08/10 20:29:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.5 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ int MaxBackends = DEF_MAXBACKENDS;
|
||||
int NBuffers = DEF_NBUFFERS;
|
||||
|
||||
#ifndef assert_enabled
|
||||
bool assert_enabled = true;
|
||||
bool assert_enabled = true;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ shmem_exit(int code)
|
||||
}
|
||||
|
||||
void
|
||||
on_shmem_exit(void (*function) (), Datum arg)
|
||||
on_shmem_exit(void (*function) (), Datum arg)
|
||||
{
|
||||
if (on_shmem_exit_index >= MAX_ON_EXITS)
|
||||
elog(FATAL, "Out of on_shmem_exit slots");
|
||||
@@ -144,17 +144,17 @@ elog(int lev, const char *fmt,...)
|
||||
|
||||
typedef struct MyStorage
|
||||
{
|
||||
PGShmemHeader header;
|
||||
int flag;
|
||||
PGSemaphoreData sem;
|
||||
} MyStorage;
|
||||
PGShmemHeader header;
|
||||
int flag;
|
||||
PGSemaphoreData sem;
|
||||
} MyStorage;
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
MyStorage *storage;
|
||||
int cpid;
|
||||
MyStorage *storage;
|
||||
int cpid;
|
||||
|
||||
printf("Creating shared memory ... ");
|
||||
fflush(stdout);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.5 2002/06/20 20:29:33 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.6 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -95,15 +95,15 @@ PosixSemaphoreCreate(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlink the semaphore immediately, so it can't be accessed externally.
|
||||
* This also ensures that it will go away if we crash.
|
||||
* Unlink the semaphore immediately, so it can't be accessed
|
||||
* externally. This also ensures that it will go away if we crash.
|
||||
*/
|
||||
sem_unlink(semname);
|
||||
|
||||
return mySem;
|
||||
}
|
||||
|
||||
#else /* !USE_NAMED_POSIX_SEMAPHORES */
|
||||
#else /* !USE_NAMED_POSIX_SEMAPHORES */
|
||||
|
||||
/*
|
||||
* PosixSemaphoreCreate
|
||||
@@ -111,7 +111,7 @@ PosixSemaphoreCreate(void)
|
||||
* Attempt to create a new unnamed semaphore.
|
||||
*/
|
||||
static void
|
||||
PosixSemaphoreCreate(sem_t *sem)
|
||||
PosixSemaphoreCreate(sem_t * sem)
|
||||
{
|
||||
if (sem_init(sem, 1, 1) < 0)
|
||||
{
|
||||
@@ -120,15 +120,14 @@ PosixSemaphoreCreate(sem_t *sem)
|
||||
proc_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* USE_NAMED_POSIX_SEMAPHORES */
|
||||
#endif /* USE_NAMED_POSIX_SEMAPHORES */
|
||||
|
||||
|
||||
/*
|
||||
* PosixSemaphoreKill - removes a semaphore
|
||||
*/
|
||||
static void
|
||||
PosixSemaphoreKill(sem_t *sem)
|
||||
PosixSemaphoreKill(sem_t * sem)
|
||||
{
|
||||
#ifdef USE_NAMED_POSIX_SEMAPHORES
|
||||
/* Got to use sem_close for named semaphores */
|
||||
@@ -149,7 +148,7 @@ PosixSemaphoreKill(sem_t *sem)
|
||||
*
|
||||
* This is called during postmaster start or shared memory reinitialization.
|
||||
* It should do whatever is needed to be able to support up to maxSemas
|
||||
* subsequent PGSemaphoreCreate calls. Also, if any system resources
|
||||
* subsequent PGSemaphoreCreate calls. Also, if any system resources
|
||||
* are acquired here or in PGSemaphoreCreate, register an on_shmem_exit
|
||||
* callback to release them.
|
||||
*
|
||||
@@ -197,7 +196,7 @@ ReleaseSemaphores(int status, Datum arg)
|
||||
void
|
||||
PGSemaphoreCreate(PGSemaphore sema)
|
||||
{
|
||||
sem_t *newsem;
|
||||
sem_t *newsem;
|
||||
|
||||
/* Can't do this in a backend, because static state is postmaster's */
|
||||
Assert(!IsUnderPostmaster);
|
||||
@@ -260,21 +259,21 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
|
||||
*
|
||||
* Each time around the loop, we check for a cancel/die interrupt. We
|
||||
* assume that if such an interrupt comes in while we are waiting, it
|
||||
* will cause the sem_wait() call to exit with errno == EINTR, so that we
|
||||
* will be able to service the interrupt (if not in a critical section
|
||||
* already).
|
||||
* will cause the sem_wait() call to exit with errno == EINTR, so that
|
||||
* we will be able to service the interrupt (if not in a critical
|
||||
* section already).
|
||||
*
|
||||
* Once we acquire the lock, we do NOT check for an interrupt before
|
||||
* returning. The caller needs to be able to record ownership of the
|
||||
* lock before any interrupt can be accepted.
|
||||
*
|
||||
* There is a window of a few instructions between CHECK_FOR_INTERRUPTS
|
||||
* and entering the sem_wait() call. If a cancel/die interrupt occurs in
|
||||
* that window, we would fail to notice it until after we acquire the
|
||||
* lock (or get another interrupt to escape the sem_wait()). We can
|
||||
* avoid this problem by temporarily setting ImmediateInterruptOK to
|
||||
* true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt in
|
||||
* this interval will execute directly. However, there is a huge
|
||||
* and entering the sem_wait() call. If a cancel/die interrupt occurs
|
||||
* in that window, we would fail to notice it until after we acquire
|
||||
* the lock (or get another interrupt to escape the sem_wait()). We
|
||||
* can avoid this problem by temporarily setting ImmediateInterruptOK
|
||||
* to true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt
|
||||
* in this interval will execute directly. However, there is a huge
|
||||
* pitfall: there is another window of a few instructions after the
|
||||
* sem_wait() before we are able to reset ImmediateInterruptOK. If an
|
||||
* interrupt occurs then, we'll lose control, which means that the
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.7 2001/11/11 22:12:00 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.8 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -26,7 +26,7 @@
|
||||
#define SEMMAX 16
|
||||
#define OPSMAX 1
|
||||
|
||||
int MaxBackends = SEMMAX;
|
||||
int MaxBackends = SEMMAX;
|
||||
|
||||
static int semid;
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.3 2002/09/02 02:47:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.4 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -58,19 +58,20 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
|
||||
#define PGSemaMagic 537 /* must be less than SEMVMX */
|
||||
|
||||
|
||||
static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so far */
|
||||
static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so
|
||||
* far */
|
||||
static int numSemaSets; /* number of sema sets acquired so far */
|
||||
static int maxSemaSets; /* allocated size of mySemaSets array */
|
||||
static IpcSemaphoreKey nextSemaKey; /* next key to try using */
|
||||
static IpcSemaphoreKey nextSemaKey; /* next key to try using */
|
||||
static int nextSemaNumber; /* next free sem num in last sema set */
|
||||
|
||||
|
||||
static IpcSemaphoreId InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
int numSems);
|
||||
int numSems);
|
||||
static void IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum,
|
||||
int value);
|
||||
int value);
|
||||
static void IpcSemaphoreKill(IpcSemaphoreId semId);
|
||||
static int IpcSemaphoreGetValue(IpcSemaphoreId semId, int semNum);
|
||||
static int IpcSemaphoreGetValue(IpcSemaphoreId semId, int semNum);
|
||||
static pid_t IpcSemaphoreGetLastPID(IpcSemaphoreId semId, int semNum);
|
||||
static IpcSemaphoreId IpcSemaphoreCreate(int numSems);
|
||||
static void ReleaseSemaphores(int status, Datum arg);
|
||||
@@ -113,7 +114,7 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems)
|
||||
* Else complain and abort
|
||||
*/
|
||||
fprintf(stderr, "IpcSemaphoreCreate: semget(key=%d, num=%d, 0%o) failed: %s\n",
|
||||
(int) semKey, numSems, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||
(int) semKey, numSems, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||
strerror(errno));
|
||||
|
||||
if (errno == ENOSPC)
|
||||
@@ -154,7 +155,7 @@ IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, int value)
|
||||
if (errno == ERANGE)
|
||||
fprintf(stderr,
|
||||
"You possibly need to raise your kernel's SEMVMX value to be at least\n"
|
||||
"%d. Look into the PostgreSQL documentation for details.\n",
|
||||
"%d. Look into the PostgreSQL documentation for details.\n",
|
||||
value);
|
||||
|
||||
proc_exit(1);
|
||||
@@ -221,7 +222,7 @@ IpcSemaphoreCreate(int numSems)
|
||||
PGSemaphoreData mysema;
|
||||
|
||||
/* Loop till we find a free IPC key */
|
||||
for (nextSemaKey++; ; nextSemaKey++)
|
||||
for (nextSemaKey++;; nextSemaKey++)
|
||||
{
|
||||
pid_t creatorPID;
|
||||
|
||||
@@ -296,12 +297,12 @@ IpcSemaphoreCreate(int numSems)
|
||||
*
|
||||
* This is called during postmaster start or shared memory reinitialization.
|
||||
* It should do whatever is needed to be able to support up to maxSemas
|
||||
* subsequent PGSemaphoreCreate calls. Also, if any system resources
|
||||
* subsequent PGSemaphoreCreate calls. Also, if any system resources
|
||||
* are acquired here or in PGSemaphoreCreate, register an on_shmem_exit
|
||||
* callback to release them.
|
||||
*
|
||||
* The port number is passed for possible use as a key (for SysV, we use
|
||||
* it to generate the starting semaphore key). In a standalone backend,
|
||||
* it to generate the starting semaphore key). In a standalone backend,
|
||||
* zero will be passed.
|
||||
*
|
||||
* In the SysV implementation, we acquire semaphore sets on-demand; the
|
||||
@@ -311,14 +312,15 @@ IpcSemaphoreCreate(int numSems)
|
||||
void
|
||||
PGReserveSemaphores(int maxSemas, int port)
|
||||
{
|
||||
maxSemaSets = (maxSemas + SEMAS_PER_SET-1) / SEMAS_PER_SET;
|
||||
maxSemaSets = (maxSemas + SEMAS_PER_SET - 1) / SEMAS_PER_SET;
|
||||
mySemaSets = (IpcSemaphoreId *)
|
||||
malloc(maxSemaSets * sizeof(IpcSemaphoreId));
|
||||
if (mySemaSets == NULL)
|
||||
elog(PANIC, "Out of memory in PGReserveSemaphores");
|
||||
numSemaSets = 0;
|
||||
nextSemaKey = port * 1000;
|
||||
nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st call */
|
||||
nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st
|
||||
* call */
|
||||
|
||||
on_shmem_exit(ReleaseSemaphores, 0);
|
||||
}
|
||||
@@ -359,7 +361,7 @@ PGSemaphoreCreate(PGSemaphore sema)
|
||||
nextSemaNumber = 0;
|
||||
}
|
||||
/* Assign the next free semaphore in the current set */
|
||||
sema->semId = mySemaSets[numSemaSets-1];
|
||||
sema->semId = mySemaSets[numSemaSets - 1];
|
||||
sema->semNum = nextSemaNumber++;
|
||||
/* Initialize it to count 1 */
|
||||
IpcSemaphoreInitialize(sema->semId, sema->semNum, 1);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.3 2002/09/02 02:47:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.4 2002/09/04 20:31:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
||||
* Else complain and abort
|
||||
*/
|
||||
fprintf(stderr, "IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %s\n",
|
||||
(int) memKey, size, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||
(int) memKey, size, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||
strerror(errno));
|
||||
|
||||
if (errno == EINVAL)
|
||||
@@ -147,7 +147,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
||||
/* use intimate shared memory on SPARC Solaris */
|
||||
memAddress = shmat(shmid, 0, SHM_SHARE_MMU);
|
||||
#else
|
||||
memAddress = shmat(shmid, 0, 0);
|
||||
memAddress = shmat(shmid, 0, 0);
|
||||
#endif
|
||||
|
||||
if (memAddress == (void *) -1)
|
||||
@@ -283,11 +283,11 @@ PrivateMemoryDelete(int status, Datum memaddr)
|
||||
* the storage.
|
||||
*
|
||||
* Dead Postgres segments are recycled if found, but we do not fail upon
|
||||
* collision with non-Postgres shmem segments. The idea here is to detect and
|
||||
* collision with non-Postgres shmem segments. The idea here is to detect and
|
||||
* re-use keys that may have been assigned by a crashed postmaster or backend.
|
||||
*
|
||||
* The port number is passed for possible use as a key (for SysV, we use
|
||||
* it to generate the starting shmem key). In a standalone backend,
|
||||
* it to generate the starting shmem key). In a standalone backend,
|
||||
* zero will be passed.
|
||||
*/
|
||||
PGShmemHeader *
|
||||
@@ -328,7 +328,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
||||
/* use intimate shared memory on SPARC Solaris */
|
||||
memAddress = shmat(shmid, 0, SHM_SHARE_MMU);
|
||||
#else
|
||||
memAddress = shmat(shmid, 0, 0);
|
||||
memAddress = shmat(shmid, 0, 0);
|
||||
#endif
|
||||
|
||||
if (memAddress == (void *) -1)
|
||||
|
Reference in New Issue
Block a user