diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 31d370ebbb2efda7192e2ed4e604ce47606612b5..43deb57aa2c2ca1e744e7f73e2d47ea6415156eb 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.478 2006/01/05 10:07:45 petere Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.479 2006/01/06 02:58:25 tgl Exp $ * * NOTES * @@ -147,7 +147,11 @@ typedef struct bkend static Dllist *BackendList; #ifdef EXEC_BACKEND -#define NUM_BACKENDARRAY_ELEMS (2*MaxBackends) +/* + * Number of entries in the backend table. Twice the number of backends, + * plus four other subprocesses (stats, bgwriter, autovac, logger). + */ +#define NUM_BACKENDARRAY_ELEMS (2*MaxBackends + 4) static Backend *ShmemBackendArray; #endif @@ -3083,6 +3087,15 @@ internal_forkexec(int argc, char *argv[], Port *port) Assert(strncmp(argv[1], "-fork", 5) == 0); Assert(argv[2] == NULL); + /* Verify that there is room in the child list */ + if (win32_numChildren >= NUM_BACKENDARRAY_ELEMS) + { + elog(LOG, "no room for child entry in backend list"); + /* Report same error as for a fork failure on Unix */ + errno = EAGAIN; + return -1; + } + /* Set up shared memory for parameter passing */ ZeroMemory(&sa, sizeof(sa)); sa.nLength = sizeof(sa);