Hi PostgreSQL developers! Jacek Drobiecki recently sent me a patch which stops postgresql to actively violate the system limit of maximum open files (RLIMIT_NOFILE) in src/backend/storage/file/fd.c, function count_usable_fds().
This avoids irritating kernel logs (if system overstep violations are enabled) and also the grsecurity alert when starting PostgreSQL. Can you please adopt this patch? Currently the modifications are only enabled when postgresql is compiled with -DCHECK_RLIMIT_NOFILE. Of course you can also use it unconditionally. Thanks for considering and have a nice day! Martin -- Martin Pitt Debian GNU/Linux Developer [EMAIL PROTECTED] [EMAIL PROTECTED] http://www.piware.de http://www.debian.org
diff -ruN postgresql-7.4.2-old/src/backend/storage/file/fd.c postgresql-7.4.2/src/backend/storage/file/fd.c --- postgresql-7.4.2-old/src/backend/storage/file/fd.c 2004-02-24 00:03:43.000000000 +0100 +++ postgresql-7.4.2/src/backend/storage/file/fd.c 2004-05-17 13:31:44.000000000 +0200 @@ -50,6 +50,9 @@ #include "storage/fd.h" #include "storage/ipc.h" +#ifdef CHECK_RLIMIT_NOFILE +#include <sys/resource.h> +#endif /* Filename components for OpenTemporaryFile */ #define PG_TEMP_FILES_DIR "pgsql_tmp" @@ -272,15 +275,28 @@ int used = 0; int highestfd = 0; int j; +#ifdef CHECK_RLIMIT_NOFILE + struct rlimit rlim; +#endif size = 1024; fd = (int *) palloc(size * sizeof(int)); +#ifdef CHECK_RLIMIT_NOFILE + getrlimit(RLIMIT_NOFILE, &rlim); +#endif + /* dup until failure ... */ for (;;) { int thisfd; +#ifdef CHECK_RLIMIT_NOFILE + /* Don't go beyond RLIMIT_NOFILE */ + if (highestfd >= rlim.rlim_cur - 1) + break; +#endif + thisfd = dup(0); if (thisfd < 0) {
signature.asc
Description: Digital signature