Skip to content

Commit 414a9a5

Browse files
macdicepull[bot]
authored andcommitted
Remove configure probe and related tests for getrlimit.
getrlimit() is in SUSv2 and all targeted systems have it. Windows doesn't have it. We could just use #ifndef WIN32, but for a little more explanation about why we're making things conditional, let's retain the HAVE_GETRLIMIT macro. It's defined in port.h for Unix systems. On systems that have it, it's not necessary to test for RLIMIT_CORE, RLIMIT_STACK or RLIMIT_NOFILE macros, since SUSv2 requires those and all targeted systems have them. Also remove references to a pre-historic alternative spelling of RLIMIT_NOFILE, and coding that seemed to believe that Cygwin didn't have it. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
1 parent bb5fd4e commit 414a9a5

File tree

10 files changed

+17
-26
lines changed

10 files changed

+17
-26
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16039,7 +16039,7 @@ fi
1603916039
LIBS_including_readline="$LIBS"
1604016040
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1604116041

16042-
for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred getrlimit inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
16042+
for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
1604316043
do :
1604416044
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1604516045
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

configure.ac

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,6 @@ AC_CHECK_FUNCS(m4_normalize([
17971797
fdatasync
17981798
getifaddrs
17991799
getpeerucred
1800-
getrlimit
18011800
inet_pton
18021801
kqueue
18031802
mbstowcs_l

src/backend/storage/file/fd.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,7 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
895895
fd = (int *) palloc(size * sizeof(int));
896896

897897
#ifdef HAVE_GETRLIMIT
898-
#ifdef RLIMIT_NOFILE /* most platforms use RLIMIT_NOFILE */
899898
getrlimit_status = getrlimit(RLIMIT_NOFILE, &rlim);
900-
#else /* but BSD doesn't ... */
901-
getrlimit_status = getrlimit(RLIMIT_OFILE, &rlim);
902-
#endif /* RLIMIT_NOFILE */
903899
if (getrlimit_status != 0)
904900
ereport(WARNING, (errmsg("getrlimit failed: %m")));
905901
#endif /* HAVE_GETRLIMIT */

src/backend/tcop/postgres.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,7 +4770,7 @@ forbidden_in_wal_sender(char firstchar)
47704770
long
47714771
get_stack_depth_rlimit(void)
47724772
{
4773-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)
4773+
#if defined(HAVE_GETRLIMIT)
47744774
static long val = 0;
47754775

47764776
/* This won't change after process launch, so check just once */
@@ -4789,13 +4789,9 @@ get_stack_depth_rlimit(void)
47894789
val = rlim.rlim_cur;
47904790
}
47914791
return val;
4792-
#else /* no getrlimit */
4793-
#if defined(WIN32) || defined(__CYGWIN__)
4792+
#else
47944793
/* On Windows we set the backend stack size in src/backend/Makefile */
47954794
return WIN32_STACK_RLIMIT;
4796-
#else /* not windows ... give up */
4797-
return -1;
4798-
#endif
47994795
#endif
48004796
}
48014797

src/bin/pg_ctl/pg_ctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static bool wait_for_postmaster_stop(void);
160160
static bool wait_for_postmaster_promote(void);
161161
static bool postmaster_is_alive(pid_t pid);
162162

163-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
163+
#if defined(HAVE_GETRLIMIT)
164164
static void unlimit_core_size(void);
165165
#endif
166166

@@ -776,7 +776,7 @@ wait_for_postmaster_promote(void)
776776
}
777777

778778

779-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
779+
#if defined(HAVE_GETRLIMIT)
780780
static void
781781
unlimit_core_size(void)
782782
{
@@ -949,7 +949,7 @@ do_start(void)
949949
if (exec_path == NULL)
950950
exec_path = find_other_exec_or_die(argv0, "postgres", PG_BACKEND_VERSIONSTR);
951951

952-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
952+
#if defined(HAVE_GETRLIMIT)
953953
if (allow_core_files)
954954
unlimit_core_size();
955955
#endif
@@ -2069,7 +2069,7 @@ do_help(void)
20692069
printf(_("If the -D option is omitted, the environment variable PGDATA is used.\n"));
20702070

20712071
printf(_("\nOptions for start or restart:\n"));
2072-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
2072+
#if defined(HAVE_GETRLIMIT)
20732073
printf(_(" -c, --core-files allow postgres to produce core files\n"));
20742074
#else
20752075
printf(_(" -c, --core-files not applicable on this platform\n"));

src/bin/pgbench/pgbench.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6662,11 +6662,7 @@ main(int argc, char **argv)
66626662
exit(1);
66636663
}
66646664
#ifdef HAVE_GETRLIMIT
6665-
#ifdef RLIMIT_NOFILE /* most platforms use RLIMIT_NOFILE */
66666665
if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
6667-
#else /* but BSD doesn't ... */
6668-
if (getrlimit(RLIMIT_OFILE, &rlim) == -1)
6669-
#endif /* RLIMIT_NOFILE */
66706666
pg_fatal("getrlimit failed: %m");
66716667
if (rlim.rlim_cur < nclients + 3)
66726668
{

src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@
229229
/* Define to 1 if you have the `getpeerucred' function. */
230230
#undef HAVE_GETPEERUCRED
231231

232-
/* Define to 1 if you have the `getrlimit' function. */
233-
#undef HAVE_GETRLIMIT
234-
235232
/* Define to 1 if you have the `gettimeofday' function. */
236233
#undef HAVE_GETTIMEOFDAY
237234

src/include/port.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,4 +519,12 @@ extern char *wait_result_to_str(int exit_status);
519519
extern bool wait_result_is_signal(int exit_status, int signum);
520520
extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_found);
521521

522+
/*
523+
* Interfaces that we assume all Unix system have. We retain individual macros
524+
* for better documentation.
525+
*/
526+
#ifndef WIN32
527+
#define HAVE_GETRLIMIT 1
528+
#endif
529+
522530
#endif /* PG_PORT_H */

src/test/regress/pg_regress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void psql_end_command(StringInfo buf, const char *database);
129129
/*
130130
* allow core files if possible.
131131
*/
132-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
132+
#if defined(HAVE_GETRLIMIT)
133133
static void
134134
unlimit_core_size(void)
135135
{
@@ -2229,7 +2229,7 @@ regression_main(int argc, char *argv[],
22292229

22302230
initialize_environment();
22312231

2232-
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
2232+
#if defined(HAVE_GETRLIMIT)
22332233
unlimit_core_size();
22342234
#endif
22352235

src/tools/msvc/Solution.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ sub GenerateFiles
271271
HAVE_GETOPT_LONG => undef,
272272
HAVE_GETPEEREID => undef,
273273
HAVE_GETPEERUCRED => undef,
274-
HAVE_GETRLIMIT => undef,
275274
HAVE_GETTIMEOFDAY => undef,
276275
HAVE_GSSAPI_GSSAPI_H => undef,
277276
HAVE_GSSAPI_H => undef,

0 commit comments

Comments
 (0)