From b6601a931c59fe8ce1d83c00c3eae61f9560f1b4 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 4 Apr 2024 08:50:30 +0200 Subject: [PATCH] audio/pulseaudio: speed up startup Instead of looping over all possible filedescriptors to close them, Use closefrom() where possible --- audio/pulseaudio/Makefile | 2 +- .../files/patch-src_pulsecore_core-util.c | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 audio/pulseaudio/files/patch-src_pulsecore_core-util.c diff --git a/audio/pulseaudio/Makefile b/audio/pulseaudio/Makefile index caf1e3cd24586..fc5b453dab175 100644 --- a/audio/pulseaudio/Makefile +++ b/audio/pulseaudio/Makefile @@ -4,7 +4,7 @@ PORTNAME= pulseaudio DISTVERSION= 16.1 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= audio MASTER_SITES= https://freedesktop.org/software/pulseaudio/releases/ diff --git a/audio/pulseaudio/files/patch-src_pulsecore_core-util.c b/audio/pulseaudio/files/patch-src_pulsecore_core-util.c new file mode 100644 index 0000000000000..f3eb4e9d25fc9 --- /dev/null +++ b/audio/pulseaudio/files/patch-src_pulsecore_core-util.c @@ -0,0 +1,24 @@ +--- src/pulsecore/core-util.c.orig 2024-04-04 06:44:07 UTC ++++ src/pulsecore/core-util.c +@@ -2849,12 +2849,19 @@ int pa_close_allv(const int except_fds[]) { + } + + #endif +- ++#if defined(__FreeBSD__) ++ maxfd = 0; ++ for (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;