git: b6601a931c59 - main - audio/pulseaudio: speed up startup

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Thu, 04 Apr 2024 06:51:57 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b6601a931c59fe8ce1d83c00c3eae61f9560f1b4

commit b6601a931c59fe8ce1d83c00c3eae61f9560f1b4
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2024-04-04 06:50:30 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2024-04-04 06:51:37 +0000

    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(-)

diff --git a/audio/pulseaudio/Makefile b/audio/pulseaudio/Makefile
index caf1e3cd2458..fc5b453dab17 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 000000000000..f3eb4e9d25fc
--- /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;