diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-11-06 16:50:18 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-11-06 16:50:18 -0400 |
commit | dd1c781903811416db4e03383a4cb0bfc8cfac40 (patch) | |
tree | 95189e98f3f3663cfa4b4bf8904e36a1ca4aa4c8 /src/backend/tcop/postgres.c | |
parent | 6736916f5f5a5f340aa20d4b27540764b5646585 (diff) | |
download | postgresql-dd1c781903811416db4e03383a4cb0bfc8cfac40.tar.gz postgresql-dd1c781903811416db4e03383a4cb0bfc8cfac40.zip |
Make get_stack_depth_rlimit() handle RLIM_INFINITY more sanely.
Rather than considering this result as meaning "unknown", report LONG_MAX.
This won't change what superusers can set max_stack_depth to, but it will
cause InitializeGUCOptions() to set the built-in default to 2MB not 100kB.
The latter seems like a fairly unreasonable interpretation of "infinity".
Per my investigation of odd buildfarm results as well as an old complaint
from Heikki.
Since this should persuade all the buildfarm animals to use a reasonable
stack depth setting during "make check", revert previous patch that dumbed
down a recursive regression test to only 5 levels.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index edf18fd0f20..60f3c7c63d0 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -19,10 +19,11 @@ #include "postgres.h" +#include <fcntl.h> +#include <limits.h> +#include <signal.h> #include <time.h> #include <unistd.h> -#include <signal.h> -#include <fcntl.h> #include <sys/socket.h> #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> @@ -4107,7 +4108,7 @@ PostgresMain(int argc, char *argv[], const char *username) /* * Obtain platform stack depth limit (in bytes) * - * Return -1 if unlimited or not known + * Return -1 if unknown */ long get_stack_depth_rlimit(void) @@ -4123,7 +4124,10 @@ get_stack_depth_rlimit(void) if (getrlimit(RLIMIT_STACK, &rlim) < 0) val = -1; else if (rlim.rlim_cur == RLIM_INFINITY) - val = -1; + val = LONG_MAX; + /* rlim_cur is probably of an unsigned type, so check for overflow */ + else if (rlim.rlim_cur >= LONG_MAX) + val = LONG_MAX; else val = rlim.rlim_cur; } |