Files
bsdports/data/postgresql11/files/patch-s00011-max_files_per_process.patch
2019-12-26 07:26:06 +00:00

55 lines
1.5 KiB
Diff

diff --git a/src/backend/storage/file/fd.c src/backend/storage/file/fd.c
index 8d2b8aacfeb..3d5bfe1a2b9 100644
--- a/src/backend/storage/file/fd.c
+++ src/backend/storage/file/fd.c
@@ -828,6 +828,7 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
int used = 0;
int highestfd = 0;
int j;
+ int fdTest = 0;
#ifdef HAVE_GETRLIMIT
struct rlimit rlim;
@@ -847,6 +848,15 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
ereport(WARNING, (errmsg("getrlimit failed: %m")));
#endif /* HAVE_GETRLIMIT */
+#ifdef WIN32
+ /*
+ * we have error on Windows7 with max_files_per_process > 1200 when dup(0) - stdin
+ * make test on postgresql.conf file
+ */
+ fdTest = _open(ConfigFileName, _O_RDONLY);
+ if (fdTest < 0)
+ fdTest = 0; /* fallback to stdin */
+#endif
/* dup until failure or probe limit reached */
for (;;)
{
@@ -862,12 +872,12 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
break;
#endif
- thisfd = dup(0);
+ thisfd = dup(fdTest);
if (thisfd < 0)
{
/* Expect EMFILE or ENFILE, else it's fishy */
if (errno != EMFILE && errno != ENFILE)
- elog(WARNING, "dup(0) failed after %d successes: %m", used);
+ elog(WARNING, "dup() failed after %d successes: %m", used);
break;
}
@@ -889,6 +899,10 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
for (j = 0; j < used; j++)
close(fd[j]);
+#ifdef WIN32
+ if (fdTest>0)
+ _close(fdTest);
+#endif
pfree(fd);
/*