mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Do a direct probe during postmaster startup to determine the maximum
number of openable files and the number already opened. This eliminates depending on sysconf(_SC_OPEN_MAX), and allows much saner behavior on platforms where open-file slots are used up by semaphores.
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.367 2004/02/17 03:54:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.368 2004/02/23 20:45:59 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -839,6 +839,12 @@ PostmasterMain(int argc, char *argv[])
|
||||
*/
|
||||
reset_shared(PostPortNumber);
|
||||
|
||||
/*
|
||||
* Estimate number of openable files. This must happen after setting up
|
||||
* semaphores, because on some platforms semaphores count as open files.
|
||||
*/
|
||||
set_max_safe_fds();
|
||||
|
||||
/*
|
||||
* Initialize the list of active backends.
|
||||
*/
|
||||
@@ -848,13 +854,10 @@ PostmasterMain(int argc, char *argv[])
|
||||
/*
|
||||
* Initialize the child pid/HANDLE arrays
|
||||
*/
|
||||
/* FIXME: [fork/exec] Ideally, we would resize these arrays with changes
|
||||
* in MaxBackends, but this'll do as a first order solution.
|
||||
*/
|
||||
win32_childPIDArray = (pid_t*)malloc(NUM_BACKENDARRAY_ELEMS*sizeof(pid_t));
|
||||
win32_childHNDArray = (HANDLE*)malloc(NUM_BACKENDARRAY_ELEMS*sizeof(HANDLE));
|
||||
if (!win32_childPIDArray || !win32_childHNDArray)
|
||||
ereport(LOG,
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user