From dd1c781903811416db4e03383a4cb0bfc8cfac40 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 6 Nov 2010 16:50:18 -0400 Subject: 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. --- src/backend/tcop/postgres.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/backend/tcop/postgres.c') 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 +#include +#include #include #include -#include -#include #include #ifdef HAVE_SYS_SELECT_H #include @@ -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; } -- cgit v1.2.3