From d654c32dc86328e9e9db42f96c9daa3a6fcd04bf Mon Sep 17 00:00:00 2001 From: Alexander Shursha Date: Fri, 29 Nov 2024 11:59:32 +0300 Subject: [PATCH] speed up startup Authored-by: Baptiste Daroussin --- src/pulsecore/core-util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 5d2bae92f..3349d0572 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2851,11 +2851,20 @@ int pa_close_allv(const int except_fds[]) { #endif +#if defined(__FreeBSD__) + maxfd = 0; + for (int i = 0; except_fds[i] >= 0; i++) + if (except_fds[i] > maxfd) + maxfd = except_fds[i]; + maxfd++; + closefrom(maxfd); +#else if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) maxfd = (int) rl.rlim_max; else maxfd = sysconf(_SC_OPEN_MAX); +#endif for (fd = 3; fd < maxfd; fd++) { int i; bool found;