diff options
Diffstat (limited to 'src/bin/scripts/scripts_parallel.c')
-rw-r--r-- | src/bin/scripts/scripts_parallel.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/bin/scripts/scripts_parallel.c b/src/bin/scripts/scripts_parallel.c index 10379a1f99b..55bda9044b4 100644 --- a/src/bin/scripts/scripts_parallel.c +++ b/src/bin/scripts/scripts_parallel.c @@ -95,20 +95,6 @@ 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. * @@ -246,6 +232,18 @@ ParallelSlotsSetup(const char *dbname, const char *host, const char *port, { conn = connectDatabase(dbname, host, port, username, prompt_password, progname, echo, false, true); + + /* + * Fail and exit immediately if trying to use a socket in an + * unsupported range. POSIX requires open(2) to use the lowest + * unused file descriptor and the hint given relies on that. + */ + if (PQsocket(conn) >= FD_SETSIZE) + { + pg_log_fatal("too many jobs for this platform -- try %d", i); + exit(1); + } + init_slot(slots + i, conn); } } |