Skip to content

Commit

Permalink
audio/pulseaudio: speed up startup
Browse files Browse the repository at this point in the history
Instead of looping over all possible filedescriptors to close them,
Use closefrom() where possible
  • Loading branch information
bapt committed Apr 4, 2024
1 parent fc136e6 commit b6601a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion audio/pulseaudio/Makefile
Expand Up @@ -4,7 +4,7 @@

PORTNAME= pulseaudio
DISTVERSION= 16.1
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= audio
MASTER_SITES= https://freedesktop.org/software/pulseaudio/releases/

Expand Down
24 changes: 24 additions & 0 deletions 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;

0 comments on commit b6601a9

Please sign in to comment.