aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/scripts_parallel.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-08-20 16:10:20 +0900
committerMichael Paquier <michael@paquier.xyz>2019-08-20 16:10:20 +0900
commit56f8f9624ba050c7c47dd97547b7fafb866f2bdd (patch)
tree22150637a021a3a7a6a197c0d0acd7b62ed80ab2 /src/bin/scripts/scripts_parallel.c
parent0431a787469265776eeb9a472beb3457d2990edb (diff)
downloadpostgresql-56f8f9624ba050c7c47dd97547b7fafb866f2bdd.tar.gz
postgresql-56f8f9624ba050c7c47dd97547b7fafb866f2bdd.zip
Fix compilation failure of vacuumdb and reindexdb with OpenBSD
FD_SETSIZE is included in sys/select.h per POSIX, and this header inclusion has been moved to scripts_parallel.c as of 5f38403 without moving the variable, causing a compilation failure on recent versions of OpenBSD (6.6 was the version used in the report). In order to take care of the failure, move FD_SETSIZE directly to scripts_parallel.c with a wrapper controlling the maximum number of parallel slots supported, based on a suggestion by Andres Freund. While on it, reduce the maximum number to be less than FD_SETSIZE, leaving some room for stdin, stdout and such as they consume some file descriptors. The buildfarm did not complain about that, as it happens to only be an issue on recent versions of OpenBSD and there is no coverage in this area. 51c3e9f fixed a similar set of issues. Bug: #15964 Reported-by: Sean Farrell Discussion: https://postgr.es/m/15964-c1753bdfed722e04@postgresql.org
Diffstat (limited to 'src/bin/scripts/scripts_parallel.c')
-rw-r--r--src/bin/scripts/scripts_parallel.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bin/scripts/scripts_parallel.c b/src/bin/scripts/scripts_parallel.c
index ffdc4e49ef8..10379a1f99b 100644
--- a/src/bin/scripts/scripts_parallel.c
+++ b/src/bin/scripts/scripts_parallel.c
@@ -95,6 +95,20 @@ select_loop(int maxFd, fd_set *workerset, bool *aborting)
}
/*
+ * ParallelSlotsMax
+ * Returns the maximum number of parallel slots supported.
+ *
+ * Note that this is included here as FD_SETSIZE is declared in sys/select.h
+ * per POSIX.
+ */
+int
+ParallelSlotsMax(void)
+{
+ /* leave some room for pre-existing fds */
+ return FD_SETSIZE - 10;
+}
+
+/*
* ParallelSlotsGetIdle
* Return a connection slot that is ready to execute a command.
*