diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-10-07 19:25:29 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-10-07 19:25:29 +0000 |
| commit | 71a6f8b85b9f748dc7f33c1212c4474e8beb901a (patch) | |
| tree | d3ae369b5edb5b1c199f4cae9d1a637432c75b15 /contrib | |
| parent | 1c160291ef61f46800616cb88d5a3a02156de4e3 (diff) | |
On platforms that have getrlimit(RLIMIT_STACK), use it to ensure that
max_stack_depth is not set to an unsafe value.
This commit also provides configure-time checking for <sys/resource.h>,
and cleans up some perhaps-unportable code associated with use of that
include file and getrlimit().
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/pgbench/pgbench.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 447e8487b0a..3c15346e899 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.56 2006/10/04 00:29:45 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.57 2006/10/07 19:25:28 tgl Exp $ * * pgbench: a simple benchmark program for PostgreSQL * written by Tatsuo Ishii @@ -37,8 +37,9 @@ #include <sys/select.h> #endif -/* for getrlimit */ -#include <sys/resource.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> /* for getrlimit */ +#endif #endif /* ! WIN32 */ extern char *optarg; @@ -1172,7 +1173,7 @@ main(int argc, char **argv) int nsocks; /* return from select(2) */ int maxsock; /* max socket number to be waited */ -#if !(defined(__CYGWIN__) || defined(__MINGW32__)) +#ifdef HAVE_GETRLIMIT struct rlimit rlim; #endif @@ -1233,8 +1234,8 @@ main(int argc, char **argv) fprintf(stderr, "invalid number of clients: %d\n", nclients); exit(1); } -#if !(defined(__CYGWIN__) || defined(__MINGW32__)) -#ifdef RLIMIT_NOFILE /* most platform uses RLIMIT_NOFILE */ +#ifdef HAVE_GETRLIMIT +#ifdef RLIMIT_NOFILE /* most platforms use RLIMIT_NOFILE */ if (getrlimit(RLIMIT_NOFILE, &rlim) == -1) #else /* but BSD doesn't ... */ if (getrlimit(RLIMIT_OFILE, &rlim) == -1) @@ -1245,11 +1246,11 @@ main(int argc, char **argv) } if (rlim.rlim_cur <= (nclients + 2)) { - fprintf(stderr, "You need at least %d open files resource but you are only allowed to use %ld.\n", nclients + 2, (long) rlim.rlim_cur); - fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n"); + fprintf(stderr, "You need at least %d open files but you are only allowed to use %ld.\n", nclients + 2, (long) rlim.rlim_cur); + fprintf(stderr, "Use limit/ulimit to increase the limit before using pgbench.\n"); exit(1); } -#endif +#endif /* HAVE_GETRLIMIT */ break; case 'C': is_connect = 1; |
