diff options
Diffstat (limited to 'src/backend/port')
| -rw-r--r-- | src/backend/port/beos/sem.c | 22 | ||||
| -rw-r--r-- | src/backend/port/beos/shm.c | 11 | ||||
| -rw-r--r-- | src/backend/port/beos/support.c | 18 | ||||
| -rw-r--r-- | src/backend/port/dynloader/aix.c | 48 | ||||
| -rw-r--r-- | src/backend/port/dynloader/aix.h | 4 | ||||
| -rw-r--r-- | src/backend/port/dynloader/bsdi.c | 11 | ||||
| -rw-r--r-- | src/backend/port/dynloader/bsdi.h | 3 | ||||
| -rw-r--r-- | src/backend/port/dynloader/hpux.c | 4 | ||||
| -rw-r--r-- | src/backend/port/dynloader/linux.c | 11 | ||||
| -rw-r--r-- | src/backend/port/dynloader/ultrix4.c | 10 | ||||
| -rw-r--r-- | src/backend/port/dynloader/win32.c | 48 | ||||
| -rw-r--r-- | src/backend/port/ipc_test.c | 6 | ||||
| -rw-r--r-- | src/backend/port/posix_sema.c | 75 | ||||
| -rw-r--r-- | src/backend/port/qnx4/sem.c | 7 | ||||
| -rw-r--r-- | src/backend/port/qnx4/shm.c | 14 | ||||
| -rw-r--r-- | src/backend/port/sysv_sema.c | 126 | ||||
| -rw-r--r-- | src/backend/port/sysv_shmem.c | 96 | ||||
| -rw-r--r-- | src/backend/port/win32/error.c | 4 | ||||
| -rw-r--r-- | src/backend/port/win32/security.c | 38 | ||||
| -rw-r--r-- | src/backend/port/win32/sema.c | 6 | ||||
| -rw-r--r-- | src/backend/port/win32/shmem.c | 4 | ||||
| -rw-r--r-- | src/backend/port/win32/signal.c | 32 | ||||
| -rw-r--r-- | src/backend/port/win32/socket.c | 14 |
23 files changed, 298 insertions, 314 deletions
diff --git a/src/backend/port/beos/sem.c b/src/backend/port/beos/sem.c index 5de018b22b..2d0dabadb3 100644 --- a/src/backend/port/beos/sem.c +++ b/src/backend/port/beos/sem.c @@ -129,8 +129,8 @@ semctl(int semId, int semNum, int flag, union semun semun) delete_sem(Address[2 * i + 1]); /* - * Reset to an invalid semId (in case other process try to get - * the infos from a cloned area + * Reset to an invalid semId (in case other process try to get the + * infos from a cloned area */ Address[2 * i + 1] = 0; } @@ -139,9 +139,9 @@ semctl(int semId, int semNum, int flag, union semun semun) Address[0] = 0; /* - * Delete the area (it might be cloned by other process. Let them - * live with it, in all cases semIds are 0 so if another process - * try to use it, it will fail + * Delete the area (it might be cloned by other process. Let them live + * with it, in all cases semIds are 0 so if another process try to use + * it, it will fail */ delete_area(semId); @@ -202,8 +202,8 @@ semget(int semKey, int semNum, int flags) /* Get an area clone (in case it's not in our address space) */ /* - * TODO : a check of address space might be done to avoid - * duplicate areas in the same address space + * TODO : a check of address space might be done to avoid duplicate + * areas in the same address space */ parea = clone_area(Nom, &Address, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, parea); return parea; @@ -218,8 +218,8 @@ semget(int semKey, int semNum, int flags) long i; /* - * Limit to 250 (8 byte per sem : 4 for the semid and 4 for - * the last pid which accessed the semaphore in a pool + * Limit to 250 (8 byte per sem : 4 for the semid and 4 for the + * last pid which accessed the semaphore in a pool */ if (semNum > 250) { @@ -291,8 +291,8 @@ semop(int semId, struct sembuf * sops, int nsops) if (sops[i].sem_op < 0) { /* - * Try acquiring the semaphore till we are not interrupted by - * a signal + * Try acquiring the semaphore till we are not interrupted by a + * signal */ if (sops[i].sem_flg == IPC_NOWAIT) { diff --git a/src/backend/port/beos/shm.c b/src/backend/port/beos/shm.c index 94da461ea2..c7791ce7b4 100644 --- a/src/backend/port/beos/shm.c +++ b/src/backend/port/beos/shm.c @@ -48,16 +48,15 @@ shmat(int memId, int m1, int m2) if (ainfo.team == teinfo.team) { /* - * the area is already in our address space, just return the - * address + * the area is already in our address space, just return the address */ return (int *) ainfo.address; } else { /* - * the area is not in our address space, clone it before and - * return the address + * the area is not in our address space, clone it before and return + * the address */ area_id narea; @@ -131,8 +130,8 @@ shmget(int memKey, int size, int flag) return -1; /* - * area does not exist and its creation is requested, create it (be - * sure to have a 4ko multiple size + * area does not exist and its creation is requested, create it (be sure + * to have a 4ko multiple size */ return create_area(nom, &Address, B_ANY_ADDRESS, ((size / 4096) + 1) * 4096, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); } diff --git a/src/backend/port/beos/support.c b/src/backend/port/beos/support.c index 3bfb6ae0d4..228889f68e 100644 --- a/src/backend/port/beos/support.c +++ b/src/backend/port/beos/support.c @@ -168,13 +168,12 @@ beos_startup(int argc, char **argv) /* Main server loop */ for (;;) { - int32 opcode = 0; + int32 opcode = 0; char datas[4000]; /* - * Wait for a message from the backend : 1 : load a shared - * object 2 : unload a shared object any other : exit support - * server + * Wait for a message from the backend : 1 : load a shared object + * 2 : unload a shared object any other : exit support server */ read_port(port_in, &opcode, datas, 4000); @@ -216,8 +215,8 @@ beos_startup(int argc, char **argv) case 2: /* - * Unload shared object and send back the result of - * the operation + * Unload shared object and send back the result of the + * operation */ write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0); break; @@ -234,10 +233,9 @@ beos_startup(int argc, char **argv) if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK); { /* - * Sometime the loader return B_OK for an - * inexistant function with an invalid address !!! - * Check that the return address is in the image - * range + * Sometime the loader return B_OK for an inexistant + * function with an invalid address !!! Check that the + * return address is in the image range */ get_image_info(addon, &info_im); diff --git a/src/backend/port/dynloader/aix.c b/src/backend/port/dynloader/aix.c index a5d355c2cc..3ace7fc391 100644 --- a/src/backend/port/dynloader/aix.c +++ b/src/backend/port/dynloader/aix.c @@ -84,8 +84,8 @@ dlopen(const char *path, int mode) static void *mainModule; /* - * Upon the first call register a terminate handler that will close - * all libraries. Also get a reference to the main module for use with + * Upon the first call register a terminate handler that will close all + * libraries. Also get a reference to the main module for use with * loadbind. */ if (!mainModule) @@ -121,8 +121,8 @@ dlopen(const char *path, int mode) } /* - * load should be declared load(const char *...). Thus we cast the - * path to a normal char *. Ugly. + * load should be declared load(const char *...). Thus we cast the path to + * a normal char *. Ugly. */ if ((mp->entry = (void *) load((char *) path, L_NOAUTODEFER, NULL)) == NULL) { @@ -134,8 +134,8 @@ dlopen(const char *path, int mode) strcat(errbuf, ": "); /* - * If AIX says the file is not executable, the error can be - * further described by querying the loader about the last error. + * If AIX says the file is not executable, the error can be further + * described by querying the loader about the last error. */ if (errno == ENOEXEC) { @@ -203,8 +203,8 @@ dlopen(const char *path, int mode) errvalid = 0; /* - * If the shared object was compiled using xlC we will need to call - * static constructors (and later on dlclose destructors). + * If the shared object was compiled using xlC we will need to call static + * constructors (and later on dlclose destructors). */ if (mp->cdtors = (CdtorPtr) dlsym(mp, "__cdtors")) { @@ -268,8 +268,8 @@ dlsym(void *handle, const char *symbol) int i; /* - * Could speed up the search, but I assume that one assigns the result - * to function pointers anyways. + * Could speed up the search, but I assume that one assigns the result to + * function pointers anyways. */ for (ep = mp->exports, i = mp->nExports; i; i--, ep++) if (strcmp(ep->name, symbol) == 0) @@ -377,8 +377,8 @@ readExports(ModulePtr mp) } /* - * The module might be loaded due to the LIBPATH environment - * variable. Search for the loaded module using L_GETINFO. + * The module might be loaded due to the LIBPATH environment variable. + * Search for the loaded module using L_GETINFO. */ if ((buf = malloc(size)) == NULL) { @@ -409,8 +409,8 @@ readExports(ModulePtr mp) } /* - * Traverse the list of loaded modules. The entry point returned - * by load() does actually point to the data segment origin. + * Traverse the list of loaded modules. The entry point returned by + * load() does actually point to the data segment origin. */ lp = (struct ld_info *) buf; while (lp) @@ -445,8 +445,8 @@ readExports(ModulePtr mp) /* * Get the padding for the data section. This is needed for AIX 4.1 - * compilers. This is used when building the final function pointer to - * the exported symbol. + * compilers. This is used when building the final function pointer to the + * exported symbol. */ if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) { @@ -466,8 +466,8 @@ readExports(ModulePtr mp) } /* - * We read the complete loader section in one chunk, this makes - * finding long symbol names residing in the string table easier. + * We read the complete loader section in one chunk, this makes finding + * long symbol names residing in the string table easier. */ if ((ldbuf = (char *) malloc(sh.s_size)) == NULL) { @@ -520,8 +520,8 @@ readExports(ModulePtr mp) } /* - * Fill in the export table. All entries are relative to the entry - * point we got from load. + * Fill in the export table. All entries are relative to the entry point + * we got from load. */ ep = mp->exports; ls = (LDSYM *) (ldbuf + LDHDRSZ); @@ -538,8 +538,8 @@ readExports(ModulePtr mp) { /* * The l_name member is not zero terminated, we must copy the - * first SYMNMLEN chars and make sure we have a zero byte at - * the end. + * first SYMNMLEN chars and make sure we have a zero byte at the + * end. */ strncpy(tmpsym, ls->l_name, SYMNMLEN); tmpsym[SYMNMLEN] = '\0'; @@ -598,8 +598,8 @@ findMain(void) } /* - * The first entry is the main module. The entry point returned by - * load() does actually point to the data segment origin. + * The first entry is the main module. The entry point returned by load() + * does actually point to the data segment origin. */ lp = (struct ld_info *) buf; ret = lp->ldinfo_dataorg; diff --git a/src/backend/port/dynloader/aix.h b/src/backend/port/dynloader/aix.h index 69e20ebae3..29d385986e 100644 --- a/src/backend/port/dynloader/aix.h +++ b/src/backend/port/dynloader/aix.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/backend/port/dynloader/aix.h,v 1.12 2003/11/29 22:39:51 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/aix.h,v 1.13 2005/10/15 02:49:23 momjian Exp $ * * @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52 * This is an unpublished work copyright (c) 1992 HELIOS Software GmbH @@ -12,7 +12,6 @@ #ifdef HAVE_DLOPEN #include <dlfcn.h> - #else /* HAVE_DLOPEN */ #ifdef __cplusplus @@ -42,7 +41,6 @@ void *dlopen(const char *path, int mode); void *dlsym(void *handle, const char *symbol); char *dlerror(void); int dlclose(void *handle); - #else void *dlopen(); void *dlsym(); diff --git a/src/backend/port/dynloader/bsdi.c b/src/backend/port/dynloader/bsdi.c index 6b17a929f4..bc51569a30 100644 --- a/src/backend/port/dynloader/bsdi.c +++ b/src/backend/port/dynloader/bsdi.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.c,v 1.26 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.c,v 1.27 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ pg_dlopen(char *filename) static int dl_initialized = 0; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -48,9 +48,8 @@ pg_dlopen(char *filename) return NULL; /* - * If undefined symbols: try to link with the C and math libraries! - * This could be smarter, if the dynamic linker was able to handle - * shared libs! + * If undefined symbols: try to link with the C and math libraries! This + * could be smarter, if the dynamic linker was able to handle shared libs! */ if (dld_undefined_sym_count > 0) { diff --git a/src/backend/port/dynloader/bsdi.h b/src/backend/port/dynloader/bsdi.h index c7f2ab5e8c..b73fa6141f 100644 --- a/src/backend/port/dynloader/bsdi.h +++ b/src/backend/port/dynloader/bsdi.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.h,v 1.21 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.h,v 1.22 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,6 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #else /* not HAVE_DLOPEN */ #define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname))) diff --git a/src/backend/port/dynloader/hpux.c b/src/backend/port/dynloader/hpux.c index b424e5b4c9..6a516387ba 100644 --- a/src/backend/port/dynloader/hpux.c +++ b/src/backend/port/dynloader/hpux.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/hpux.c,v 1.27 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/hpux.c,v 1.28 2005/10/15 02:49:23 momjian Exp $ * * NOTES * all functions are defined here -- it's impossible to trace the @@ -34,7 +34,7 @@ pg_dlopen(char *filename) * call the library! */ shl_t handle = shl_load(filename, - BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH, + BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH, 0L); return (void *) handle; diff --git a/src/backend/port/dynloader/linux.c b/src/backend/port/dynloader/linux.c index 325e8f9920..e62431140c 100644 --- a/src/backend/port/dynloader/linux.c +++ b/src/backend/port/dynloader/linux.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/linux.c,v 1.30 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/linux.c,v 1.31 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,8 +38,8 @@ pg_dlopen(char *filename) static int dl_initialized = 0; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -60,9 +60,8 @@ pg_dlopen(char *filename) return NULL; /* - * If undefined symbols: try to link with the C and math libraries! - * This could be smarter, if the dynamic linker was able to handle - * shared libs! + * If undefined symbols: try to link with the C and math libraries! This + * could be smarter, if the dynamic linker was able to handle shared libs! */ if (dld_undefined_sym_count > 0) { diff --git a/src/backend/port/dynloader/ultrix4.c b/src/backend/port/dynloader/ultrix4.c index c0e4555a38..c631538083 100644 --- a/src/backend/port/dynloader/ultrix4.c +++ b/src/backend/port/dynloader/ultrix4.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/ultrix4.c,v 1.22 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/ultrix4.c,v 1.23 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ pg_dlopen(char *filename) void *handle; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -43,8 +43,8 @@ pg_dlopen(char *filename) } /* - * open the file. We do the symbol resolution right away so that we - * will know if there are undefined symbols. (This is in fact the same + * open the file. We do the symbol resolution right away so that we will + * know if there are undefined symbols. (This is in fact the same * semantics as "ld -A". ie. you cannot have undefined symbols. */ if ((handle = dl_open(filename, DL_NOW)) == NULL) diff --git a/src/backend/port/dynloader/win32.c b/src/backend/port/dynloader/win32.c index c2c496a529..c2547f5a28 100644 --- a/src/backend/port/dynloader/win32.c +++ b/src/backend/port/dynloader/win32.c @@ -1,31 +1,32 @@ -/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.6 2005/08/12 21:23:10 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.7 2005/10/15 02:49:23 momjian Exp $ */ #include <windows.h> #include <stdio.h> -char *dlerror(void); -int dlclose(void *handle); -void *dlsym(void *handle, const char *symbol); -void *dlopen(const char *path, int mode); +char *dlerror(void); +int dlclose(void *handle); +void *dlsym(void *handle, const char *symbol); +void *dlopen(const char *path, int mode); static char last_dyn_error[512]; -static void set_dl_error(void) +static void +set_dl_error(void) { - DWORD err = GetLastError(); + DWORD err = GetLastError(); if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - last_dyn_error, - sizeof(last_dyn_error)-1, - NULL) == 0) + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + last_dyn_error, + sizeof(last_dyn_error) - 1, + NULL) == 0) { - snprintf(last_dyn_error, sizeof(last_dyn_error)-1, - "unknown error %lu", err); - } + snprintf(last_dyn_error, sizeof(last_dyn_error) - 1, + "unknown error %lu", err); + } } char * @@ -52,9 +53,10 @@ dlclose(void *handle) void * dlsym(void *handle, const char *symbol) { - void *ptr; + void *ptr; + ptr = GetProcAddress((HMODULE) handle, symbol); - if (!ptr) + if (!ptr) { set_dl_error(); return NULL; @@ -66,15 +68,15 @@ dlsym(void *handle, const char *symbol) void * dlopen(const char *path, int mode) { - HMODULE h; - int prevmode; + HMODULE h; + int prevmode; /* Disable popup error messages when loading DLLs */ prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); h = LoadLibrary(path); SetErrorMode(prevmode); - - if (!h) + + if (!h) { set_dl_error(); return NULL; diff --git a/src/backend/port/ipc_test.c b/src/backend/port/ipc_test.c index 3e2068f19a..89ebe1ded7 100644 --- a/src/backend/port/ipc_test.c +++ b/src/backend/port/ipc_test.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/ipc_test.c,v 1.17 2005/02/05 20:07:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/ipc_test.c,v 1.18 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ proc_exit(int code) shmem_exit(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); exit(code); } @@ -84,7 +84,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; } diff --git a/src/backend/port/posix_sema.c b/src/backend/port/posix_sema.c index d222901107..2024b3ebde 100644 --- a/src/backend/port/posix_sema.c +++ b/src/backend/port/posix_sema.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/posix_sema.c,v 1.13 2004/12/31 22:00:29 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/posix_sema.c,v 1.14 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,14 +93,13 @@ 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 */ /* @@ -243,38 +242,36 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. * - * 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). + * 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). * * 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. + * 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 - * 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 - * lock has been acquired but our caller did not get a chance to - * record the fact. Therefore, we only set ImmediateInterruptOK if the - * caller tells us it's OK to do so, ie, the caller does not need to - * record acquiring the lock. (This is currently true for lockmanager - * locks, since the process that granted us the lock did all the - * necessary state updates. It's not true for Posix semaphores used to - * implement LW locks or emulate spinlocks --- but the wait time for - * such locks should not be very long, anyway.) + * 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 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 lock has been acquired but our caller did + * not get a chance to record the fact. Therefore, we only set + * ImmediateInterruptOK if the caller tells us it's OK to do so, ie, the + * caller does not need to record acquiring the lock. (This is currently + * true for lockmanager locks, since the process that granted us the lock + * did all the necessary state updates. It's not true for Posix semaphores + * used to implement LW locks or emulate spinlocks --- but the wait time + * for such locks should not be very long, anyway.) */ do { @@ -299,10 +296,10 @@ PGSemaphoreUnlock(PGSemaphore sema) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and unlock the semaphore again. Not clear this - * can really happen, but might as well cope. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and unlock the semaphore again. Not clear this can really happen, + * but might as well cope. */ do { @@ -324,9 +321,9 @@ PGSemaphoreTryLock(PGSemaphore sema) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. */ do { diff --git a/src/backend/port/qnx4/sem.c b/src/backend/port/qnx4/sem.c index 484a85b6fc..4a8d6a348f 100644 --- a/src/backend/port/qnx4/sem.c +++ b/src/backend/port/qnx4/sem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.12 2003/11/29 19:51:54 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.13 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,8 +47,7 @@ struct sem_set_info int nsems; sem_t sem[SEMMAX]; /* array of POSIX semaphores */ struct sem semV[SEMMAX]; /* array of System V semaphore structures */ - struct pending_ops pendingOps[SEMMAX]; /* array of pending - * operations */ + struct pending_ops pendingOps[SEMMAX]; /* array of pending operations */ }; struct sem_info @@ -189,7 +188,7 @@ semget(key_t key, int nsems, int semflg) fprintf(stderr, "Found a pre-existing shared memory block for the semaphore memory\n" "of a different size (%ld instead %ld). Make sure that all executables\n" - "are from the same release or remove the file \"/dev/shmem/%s\"\n" + "are from the same release or remove the file \"/dev/shmem/%s\"\n" "left by a previous version.\n", (long) statbuf.st_size, (long) sem_info_size, diff --git a/src/backend/port/qnx4/shm.c b/src/backend/port/qnx4/shm.c index fc2a70aa8f..7dde22773e 100644 --- a/src/backend/port/qnx4/shm.c +++ b/src/backend/port/qnx4/shm.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.9 2003/11/29 19:51:54 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.10 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -200,8 +200,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) case IPC_STAT: /* - * we have to open it first. stat() does no prefix tracking -> - * the call would go to fsys instead of proc + * we have to open it first. stat() does no prefix tracking -> the + * call would go to fsys instead of proc */ keytoname(shmid, name); fd = shm_open(name, 0, MODE); @@ -210,8 +210,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) result = fstat(fd, &statbuf); /* - * if the file exists, subtract 2 from linkcount : one for - * our own open and one for the dir entry + * if the file exists, subtract 2 from linkcount : one for our + * own open and one for the dir entry */ if (!result) buf->shm_nattch = statbuf.st_nlink - 2; @@ -221,8 +221,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) else { /* - * if there's no entry for this key it doesn't matter the - * next shmget() would get a different shm anyway + * if there's no entry for this key it doesn't matter the next + * shmget() would get a different shm anyway */ buf->shm_nattch = 0; return 0; diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c index 1d44a40033..d42e8c8768 100644 --- a/src/backend/port/sysv_sema.c +++ b/src/backend/port/sysv_sema.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.16 2004/12/31 22:00:29 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.17 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,8 +58,7 @@ 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 */ @@ -97,11 +96,10 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) if (semId < 0) { /* - * Fail quietly if error indicates a collision with existing set. - * One would expect EEXIST, given that we said IPC_EXCL, but - * perhaps we could get a permission violation instead? Also, - * EIDRM might occur if an old set is slated for destruction but - * not gone yet. + * Fail quietly if error indicates a collision with existing set. One + * would expect EEXIST, given that we said IPC_EXCL, but perhaps we + * could get a permission violation instead? Also, EIDRM might occur + * if an old set is slated for destruction but not gone yet. */ if (errno == EEXIST || errno == EACCES #ifdef EIDRM @@ -120,13 +118,13 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) IPC_CREAT | IPC_EXCL | IPCProtection), (errno == ENOSPC) ? errhint("This error does *not* mean that you have run out of disk space.\n" - "It occurs when either the system limit for the maximum number of " - "semaphore sets (SEMMNI), or the system wide maximum number of " - "semaphores (SEMMNS), would be exceeded. You need to raise the " - "respective kernel parameter. Alternatively, reduce PostgreSQL's " - "consumption of semaphores by reducing its max_connections parameter " + "It occurs when either the system limit for the maximum number of " + "semaphore sets (SEMMNI), or the system wide maximum number of " + "semaphores (SEMMNS), would be exceeded. You need to raise the " + "respective kernel parameter. Alternatively, reduce PostgreSQL's " + "consumption of semaphores by reducing its max_connections parameter " "(currently %d).\n" - "The PostgreSQL documentation contains more information about " + "The PostgreSQL documentation contains more information about " "configuring your system for PostgreSQL.", MaxBackends) : 0)); } @@ -149,7 +147,7 @@ IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, int value) semId, semNum, value), (errno == ERANGE) ? errhint("You possibly need to raise your kernel's SEMVMX value to be at least " - "%d. Look into the PostgreSQL documentation for details.", + "%d. Look into the PostgreSQL documentation for details.", value) : 0)); } @@ -224,8 +222,8 @@ IpcSemaphoreCreate(int numSems) continue; /* sema belongs to a non-Postgres app */ /* - * If the creator PID is my own PID or does not belong to any - * extant process, it's safe to zap it. + * If the creator PID is my own PID or does not belong to any extant + * process, it's safe to zap it. */ creatorPID = IpcSemaphoreGetLastPID(semId, numSems); if (creatorPID <= 0) @@ -237,11 +235,10 @@ IpcSemaphoreCreate(int numSems) } /* - * The sema set appears to be from a dead Postgres process, or - * from a previous cycle of life in this same process. Zap it, if - * possible. This probably shouldn't fail, but if it does, assume - * the sema set belongs to someone else after all, and continue - * quietly. + * The sema set appears to be from a dead Postgres process, or from a + * previous cycle of life in this same process. Zap it, if possible. + * This probably shouldn't fail, but if it does, assume the sema set + * belongs to someone else after all, and continue quietly. */ semun.val = 0; /* unused, but keep compiler quiet */ if (semctl(semId, 0, IPC_RMID, semun) < 0) @@ -255,17 +252,17 @@ IpcSemaphoreCreate(int numSems) break; /* successful create */ /* - * Can only get here if some other process managed to create the - * same sema key before we did. Let him have that one, loop - * around to try next key. + * Can only get here if some other process managed to create the same + * sema key before we did. Let him have that one, loop around to try + * next key. */ } /* - * OK, we created a new sema set. Mark it as created by this process. - * We do this by setting the spare semaphore to PGSemaMagic-1 and then - * incrementing it with semop(). That leaves it with value - * PGSemaMagic and sempid referencing this process. + * OK, we created a new sema set. Mark it as created by this process. We + * do this by setting the spare semaphore to PGSemaMagic-1 and then + * incrementing it with semop(). That leaves it with value PGSemaMagic + * and sempid referencing this process. */ IpcSemaphoreInitialize(semId, numSems, PGSemaMagic - 1); mysema.semId = semId; @@ -303,8 +300,7 @@ PGReserveSemaphores(int maxSemas, int port) elog(PANIC, "out of memory"); 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); } @@ -378,38 +374,36 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. * - * 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 semop() call to exit with errno == EINTR, so that we - * will be able to service the interrupt (if not in a critical section - * already). + * 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 semop() 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. + * 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 semop() 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 semop()). 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 - * semop() before we are able to reset ImmediateInterruptOK. If an - * interrupt occurs then, we'll lose control, which means that the - * lock has been acquired but our caller did not get a chance to - * record the fact. Therefore, we only set ImmediateInterruptOK if the - * caller tells us it's OK to do so, ie, the caller does not need to - * record acquiring the lock. (This is currently true for lockmanager - * locks, since the process that granted us the lock did all the - * necessary state updates. It's not true for SysV semaphores used to - * implement LW locks or emulate spinlocks --- but the wait time for - * such locks should not be very long, anyway.) + * There is a window of a few instructions between CHECK_FOR_INTERRUPTS and + * entering the semop() 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 semop()). 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 semop() before we are able to + * reset ImmediateInterruptOK. If an interrupt occurs then, we'll lose + * control, which means that the lock has been acquired but our caller did + * not get a chance to record the fact. Therefore, we only set + * ImmediateInterruptOK if the caller tells us it's OK to do so, ie, the + * caller does not need to record acquiring the lock. (This is currently + * true for lockmanager locks, since the process that granted us the lock + * did all the necessary state updates. It's not true for SysV semaphores + * used to implement LW locks or emulate spinlocks --- but the wait time + * for such locks should not be very long, anyway.) */ do { @@ -439,10 +433,10 @@ PGSemaphoreUnlock(PGSemaphore sema) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and unlock the semaphore again. Not clear this - * can really happen, but might as well cope. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and unlock the semaphore again. Not clear this can really happen, + * but might as well cope. */ do { @@ -469,9 +463,9 @@ PGSemaphoreTryLock(PGSemaphore sema) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. */ do { diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 23b945f085..3092ca2a37 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.43 2005/08/20 23:26:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.44 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,11 +81,10 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) if (shmid < 0) { /* - * Fail quietly if error indicates a collision with existing - * segment. One would expect EEXIST, given that we said IPC_EXCL, - * but perhaps we could get a permission violation instead? Also, - * EIDRM might occur if an old seg is slated for destruction but - * not gone yet. + * Fail quietly if error indicates a collision with existing segment. + * One would expect EEXIST, given that we said IPC_EXCL, but perhaps + * we could get a permission violation instead? Also, EIDRM might + * occur if an old seg is slated for destruction but not gone yet. */ if (errno == EEXIST || errno == EACCES #ifdef EIDRM @@ -99,41 +98,41 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) */ ereport(FATAL, (errmsg("could not create shared memory segment: %m"), - errdetail("Failed system call was shmget(key=%lu, size=%lu, 0%o).", - (unsigned long) memKey, (unsigned long) size, - IPC_CREAT | IPC_EXCL | IPCProtection), + errdetail("Failed system call was shmget(key=%lu, size=%lu, 0%o).", + (unsigned long) memKey, (unsigned long) size, + IPC_CREAT | IPC_EXCL | IPCProtection), (errno == EINVAL) ? errhint("This error usually means that PostgreSQL's request for a shared memory " - "segment exceeded your kernel's SHMMAX parameter. You can either " + "segment exceeded your kernel's SHMMAX parameter. You can either " "reduce the request size or reconfigure the kernel with larger SHMMAX. " - "To reduce the request size (currently %lu bytes), reduce " - "PostgreSQL's shared_buffers parameter (currently %d) and/or " + "To reduce the request size (currently %lu bytes), reduce " + "PostgreSQL's shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" "If the request size is already small, it's possible that it is less than " "your kernel's SHMMIN parameter, in which case raising the request size or " "reconfiguring SHMMIN is called for.\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0, (errno == ENOMEM) ? errhint("This error usually means that PostgreSQL's request for a shared " - "memory segment exceeded available memory or swap space. " - "To reduce the request size (currently %lu bytes), reduce " - "PostgreSQL's shared_buffers parameter (currently %d) and/or " + "memory segment exceeded available memory or swap space. " + "To reduce the request size (currently %lu bytes), reduce " + "PostgreSQL's shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0, (errno == ENOSPC) ? errhint("This error does *not* mean that you have run out of disk space. " "It occurs either if all available shared memory IDs have been taken, " "in which case you need to raise the SHMMNI parameter in your kernel, " - "or because the system's overall limit for shared memory has been " - "reached. If you cannot increase the shared memory limit, " - "reduce PostgreSQL's shared memory request (currently %lu bytes), " - "by reducing its shared_buffers parameter (currently %d) and/or " + "or because the system's overall limit for shared memory has been " + "reached. If you cannot increase the shared memory limit, " + "reduce PostgreSQL's shared memory request (currently %lu bytes), " + "by reducing its shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0)); } @@ -187,7 +186,7 @@ IpcMemoryDelete(int status, Datum shmId) * Is a previously-existing shmem segment still existing and in use? * * The point of this exercise is to detect the case where a prior postmaster - * crashed, but it left child backends that are still running. Therefore + * crashed, but it left child backends that are still running. Therefore * we only care about shmem segments that are associated with the intended * DataDir. This is an important consideration since accidental matches of * shmem segment IDs are reasonably common. @@ -197,35 +196,38 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2) { IpcMemoryId shmId = (IpcMemoryId) id2; struct shmid_ds shmStat; + #ifndef WIN32 struct stat statbuf; PGShmemHeader *hdr; #endif /* - * We detect whether a shared memory segment is in use by seeing - * whether it (a) exists and (b) has any processes are attached to it. + * We detect whether a shared memory segment is in use by seeing whether + * it (a) exists and (b) has any processes are attached to it. */ if (shmctl(shmId, IPC_STAT, &shmStat) < 0) { /* * EINVAL actually has multiple possible causes documented in the - * shmctl man page, but we assume it must mean the segment no - * longer exists. + * shmctl man page, but we assume it must mean the segment no longer + * exists. */ if (errno == EINVAL) return false; + /* - * EACCES implies that the segment belongs to some other userid, - * which means it is not a Postgres shmem segment (or at least, - * not one that is relevant to our data directory). + * EACCES implies that the segment belongs to some other userid, which + * means it is not a Postgres shmem segment (or at least, not one that + * is relevant to our data directory). */ if (errno == EACCES) return false; + /* - * Otherwise, we had better assume that the segment is in use. - * The only likely case is EIDRM, which implies that the segment - * has been IPC_RMID'd but there are still processes attached to it. + * Otherwise, we had better assume that the segment is in use. The + * only likely case is EIDRM, which implies that the segment has been + * IPC_RMID'd but there are still processes attached to it. */ return true; } @@ -295,6 +297,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) void *memAddress; PGShmemHeader *hdr; IpcMemoryId shmid; + #ifndef WIN32 struct stat statbuf; #endif @@ -338,11 +341,10 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) } /* - * The segment appears to be from a dead Postgres process, or from - * a previous cycle of life in this same process. Zap it, if - * possible. This probably shouldn't fail, but if it does, assume - * the segment belongs to someone else after all, and continue - * quietly. + * The segment appears to be from a dead Postgres process, or from a + * previous cycle of life in this same process. Zap it, if possible. + * This probably shouldn't fail, but if it does, assume the segment + * belongs to someone else after all, and continue quietly. */ shmdt(memAddress); if (shmctl(shmid, IPC_RMID, NULL) < 0) @@ -356,17 +358,16 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) break; /* successful create and attach */ /* - * Can only get here if some other process managed to create the - * same shmem key before we did. Let him have that one, loop - * around to try next key. + * Can only get here if some other process managed to create the same + * shmem key before we did. Let him have that one, loop around to try + * next key. */ } /* - * OK, we created a new segment. Mark it as created by this process. - * The order of assignments here is critical so that another Postgres - * process can't see the header as valid but belonging to an invalid - * PID! + * OK, we created a new segment. Mark it as created by this process. The + * order of assignments here is critical so that another Postgres process + * can't see the header as valid but belonging to an invalid PID! */ hdr = (PGShmemHeader *) memAddress; hdr->creatorPID = getpid(); @@ -401,7 +402,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) /* * PGSharedMemoryReAttach * - * Re-attach to an already existing shared memory segment. In the non + * Re-attach to an already existing shared memory segment. In the non * EXEC_BACKEND case this is not used, because postmaster children inherit * the shared memory segment attachment via fork(). * @@ -436,8 +437,7 @@ PGSharedMemoryReAttach(void) UsedShmemSegAddr = hdr; /* probably redundant */ } - -#endif /* EXEC_BACKEND */ +#endif /* EXEC_BACKEND */ /* * PGSharedMemoryDetach diff --git a/src/backend/port/win32/error.c b/src/backend/port/win32/error.c index c7f0a24f10..eb660a3ef8 100644 --- a/src/backend/port/win32/error.c +++ b/src/backend/port/win32/error.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.5 2005/10/07 16:34:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.6 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -178,7 +178,7 @@ _dosmaperr(unsigned long e) errno = doserrors[i].doserr; ereport(DEBUG5, (errmsg_internal("mapped win32 error code %lu to %d", - e, errno))); + e, errno))); return; } } diff --git a/src/backend/port/win32/security.c b/src/backend/port/win32/security.c index 9283f3f694..f610b89361 100644 --- a/src/backend/port/win32/security.c +++ b/src/backend/port/win32/security.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/security.c,v 1.8 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/security.c,v 1.9 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,8 +15,8 @@ static BOOL pgwin32_get_dynamic_tokeninfo(HANDLE token, - TOKEN_INFORMATION_CLASS class, char **InfoBuffer, - char *errbuf, int errsize); + TOKEN_INFORMATION_CLASS class, char **InfoBuffer, + char *errbuf, int errsize); /* * Returns nonzero if the current user has administrative privileges, @@ -30,7 +30,7 @@ pgwin32_is_admin(void) { HANDLE AccessToken; char *InfoBuffer = NULL; - char errbuf[256]; + char errbuf[256]; PTOKEN_GROUPS Groups; PSID AdministratorsSid; PSID PowerUsersSid; @@ -57,7 +57,7 @@ pgwin32_is_admin(void) CloseHandle(AccessToken); if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, + SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsSid)) { write_stderr("could not get SID for Administrators group: error code %d\n", @@ -66,7 +66,7 @@ pgwin32_is_admin(void) } if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, + SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, 0, &PowerUsersSid)) { write_stderr("could not get SID for PowerUsers group: error code %d\n", @@ -114,8 +114,8 @@ pgwin32_is_service(void) { static int _is_service = -1; HANDLE AccessToken; - char *InfoBuffer = NULL; - char errbuf[256]; + char *InfoBuffer = NULL; + char errbuf[256]; PTOKEN_GROUPS Groups; PTOKEN_USER User; PSID ServiceSid; @@ -138,14 +138,14 @@ pgwin32_is_service(void) if (!pgwin32_get_dynamic_tokeninfo(AccessToken, TokenUser, &InfoBuffer, errbuf, sizeof(errbuf))) { - fprintf(stderr,errbuf); + fprintf(stderr, errbuf); return -1; } User = (PTOKEN_USER) InfoBuffer; if (!AllocateAndInitializeSid(&NtAuthority, 1, - SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, + SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &LocalSystemSid)) { fprintf(stderr, "could not get SID for local system account\n"); @@ -169,14 +169,14 @@ pgwin32_is_service(void) if (!pgwin32_get_dynamic_tokeninfo(AccessToken, TokenGroups, &InfoBuffer, errbuf, sizeof(errbuf))) { - fprintf(stderr,errbuf); + fprintf(stderr, errbuf); return -1; } Groups = (PTOKEN_GROUPS) InfoBuffer; if (!AllocateAndInitializeSid(&NtAuthority, 1, - SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0, + SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0, &ServiceSid)) { fprintf(stderr, "could not get SID for service group\n"); @@ -213,17 +213,17 @@ static BOOL pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class, char **InfoBuffer, char *errbuf, int errsize) { - DWORD InfoBufferSize; + DWORD InfoBufferSize; if (GetTokenInformation(token, class, NULL, 0, &InfoBufferSize)) { - snprintf(errbuf,errsize,"could not get token information: got zero size\n"); + snprintf(errbuf, errsize, "could not get token information: got zero size\n"); return FALSE; } if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { - snprintf(errbuf,errsize,"could not get token information: error code %d\n", + snprintf(errbuf, errsize, "could not get token information: error code %d\n", (int) GetLastError()); return FALSE; } @@ -231,18 +231,18 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class, *InfoBuffer = malloc(InfoBufferSize); if (*InfoBuffer == NULL) { - snprintf(errbuf,errsize,"could not allocate %d bytes for token information\n", + snprintf(errbuf, errsize, "could not allocate %d bytes for token information\n", (int) InfoBufferSize); return FALSE; } - if (!GetTokenInformation(token, class, *InfoBuffer, + if (!GetTokenInformation(token, class, *InfoBuffer, InfoBufferSize, &InfoBufferSize)) { - snprintf(errbuf,errsize,"could not get token information: error code %d\n", + snprintf(errbuf, errsize, "could not get token information: error code %d\n", (int) GetLastError()); return FALSE; } - + return TRUE; } diff --git a/src/backend/port/win32/sema.c b/src/backend/port/win32/sema.c index 7942e696e3..a9d62f057f 100644 --- a/src/backend/port/win32/sema.c +++ b/src/backend/port/win32/sema.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.10 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.11 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -216,8 +216,8 @@ semop(int semId, struct sembuf * sops, int nsops) if (nsops != 1) { /* - * Not supported (we return on 1st success, and don't cancel - * earlier ops) + * Not supported (we return on 1st success, and don't cancel earlier + * ops) */ errno = E2BIG; return -1; diff --git a/src/backend/port/win32/shmem.c b/src/backend/port/win32/shmem.c index 49f5696ceb..dbb9cdc0f1 100644 --- a/src/backend/port/win32/shmem.c +++ b/src/backend/port/win32/shmem.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.10 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.11 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ shmat(int memId, void *shmaddr, int flag) /* TODO -- shmat needs to count # attached to shared mem */ void *lpmem = MapViewOfFileEx((HANDLE) memId, FILE_MAP_WRITE | FILE_MAP_READ, - 0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */ , shmaddr); + 0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */ , shmaddr); if (lpmem == NULL) { diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c index e0c9dba16f..a32427f28f 100644 --- a/src/backend/port/win32/signal.c +++ b/src/backend/port/win32/signal.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.11 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.12 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]; static int pg_signal_mask; DLLIMPORT HANDLE pgwin32_signal_event; -HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; +HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; /* Signal handling thread function */ @@ -73,12 +73,12 @@ pgwin32_signal_initialize(void) signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL); if (signal_thread_handle == NULL) ereport(FATAL, - (errmsg_internal("failed to create signal handler thread"))); + (errmsg_internal("failed to create signal handler thread"))); /* Create console control handle to pick up Ctrl-C etc */ if (!SetConsoleCtrlHandler(pg_console_handler, TRUE)) ereport(FATAL, - (errmsg_internal("failed to set console control handler"))); + (errmsg_internal("failed to set console control handler"))); } @@ -112,9 +112,9 @@ pgwin32_dispatch_queued_signals(void) LeaveCriticalSection(&pg_signal_crit_sec); sig(i); EnterCriticalSection(&pg_signal_crit_sec); - break; /* Restart outer loop, in case signal mask - * or queue has been modified inside - * signal handler */ + break; /* Restart outer loop, in case signal mask or + * queue has been modified inside signal + * handler */ } } } @@ -133,8 +133,8 @@ pqsigsetmask(int mask) pg_signal_mask = mask; /* - * Dispatch any signals queued up right away, in case we have - * unblocked one or more signals previously queued + * Dispatch any signals queued up right away, in case we have unblocked + * one or more signals previously queued */ pgwin32_dispatch_queued_signals(); @@ -165,7 +165,7 @@ pgwin32_create_signal_listener(pid_t pid) wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", (int) pid); pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); if (pipe == INVALID_HANDLE_VALUE) @@ -218,8 +218,8 @@ pg_signal_dispatch_thread(LPVOID param) CloseHandle(pipe); return 0; } - WriteFile(pipe, &sigNum, 1, &bytes, NULL); /* Don't care if it works - * or not.. */ + WriteFile(pipe, &sigNum, 1, &bytes, NULL); /* Don't care if it works or + * not.. */ FlushFileBuffers(pipe); DisconnectNamedPipe(pipe); CloseHandle(pipe); @@ -233,7 +233,7 @@ static DWORD WINAPI pg_signal_thread(LPVOID param) { char pipename[128]; - HANDLE pipe = pgwin32_initial_signal_pipe; + HANDLE pipe = pgwin32_initial_signal_pipe; wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", GetCurrentProcessId()); @@ -245,8 +245,8 @@ pg_signal_thread(LPVOID param) if (pipe == INVALID_HANDLE_VALUE) { pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); if (pipe == INVALID_HANDLE_VALUE) { @@ -260,7 +260,7 @@ pg_signal_thread(LPVOID param) if (fConnected) { hThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread, + (LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread, (LPVOID) pipe, 0, NULL); if (hThread == INVALID_HANDLE_VALUE) write_stderr("could not create signal dispatch thread: error code %d\n", diff --git a/src/backend/port/win32/socket.c b/src/backend/port/win32/socket.c index e65197e4d9..808977a237 100644 --- a/src/backend/port/win32/socket.c +++ b/src/backend/port/win32/socket.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.8 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.9 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -178,8 +178,8 @@ pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen) SOCKET rs; /* - * Poll for signals, but don't return with EINTR, since we don't - * handle that in pqcomm.c + * Poll for signals, but don't return with EINTR, since we don't handle + * that in pqcomm.c */ pgwin32_poll_signals(); @@ -351,8 +351,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c if (WSAGetLastError() != WSAEWOULDBLOCK) /* - * Not completed, and not just "would block", so an - * error occured + * Not completed, and not just "would block", so an error + * occured */ FD_SET(writefds->fd_array[i], &outwritefds); } @@ -423,8 +423,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c if (r != WAIT_TIMEOUT && r != WAIT_IO_COMPLETION && r != (WAIT_OBJECT_0 + numevents)) { /* - * We scan all events, even those not signalled, in case more than - * one event has been tagged but Wait.. can only return one. + * We scan all events, even those not signalled, in case more than one + * event has been tagged but Wait.. can only return one. */ WSANETWORKEVENTS resEvents; |
