FreeBSD Bugzilla – Attachment 209087 Details for
Bug 236815
[patch] devel/glib20: loops over all possible file descriptors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
more faster
glib20_gspawn.patch (text/plain), 2.07 KB, created by
Ivan Rozhuk
on 2019-11-12 07:31:03 UTC
(
hide
)
Description:
more faster
Filename:
MIME Type:
Creator:
Ivan Rozhuk
Created:
2019-11-12 07:31:03 UTC
Size:
2.07 KB
patch
obsolete
>Index: devel/glib20/files/patch-glib_gspawn.c >=================================================================== >--- devel/glib20/files/patch-glib_gspawn.c (nonexistent) >+++ devel/glib20/files/patch-glib_gspawn.c (working copy) >@@ -0,0 +1,83 @@ >+--- glib/gspawn.c 2018-09-21 12:29:23.000000000 +0300 >++++ glib/gspawn.c 2019-07-20 18:05:15.486558000 +0300 >+@@ -39,6 +39,13 @@ >+ #include <sys/resource.h> >+ #endif /* HAVE_SYS_RESOURCE_H */ >+ >++#ifdef __FreeBSD__ >++#include <sys/param.h> >++#include <sys/sysctl.h> >++#include <sys/user.h> >++#include <sys/file.h> >++#endif >++ >+ #include "gspawn.h" >+ #include "gthread.h" >+ #include "glib/gstdio.h" >+@@ -1077,7 +1084,53 @@ set_cloexec (void *data, gint fd) >+ } >+ >+ #ifndef HAVE_FDWALK >++ >++#ifdef __FreeBSD__ >+ static int >++fdwalk2(int (*func)(void *, int), void *udata, int *ret) { >++ size_t i, bufsz = 0; >++ struct xfile *xfbuf, *xf; >++ int uret = 0, pid_found = 0; >++ int mib[2] = { CTL_KERN, KERN_FILE }; >++ pid_t pid; >++ >++ if (NULL == func) >++ return EINVAL; >++ >++ if (sysctl (mib, nitems(mib), NULL, &bufsz, NULL, 0) == -1) >++ return (errno); >++ bufsz += 65536; >++ xfbuf = alloca (bufsz); >++ if (xfbuf == NULL) >++ return errno; >++ if (sysctl (mib, 2, xfbuf, &bufsz, NULL, 0) == -1) >++ return errno; >++ bufsz /= sizeof(struct xfile); >++ >++ pid = getpid(); >++ for (i = 0; i < bufsz; i++) { >++ xf = &xfbuf[i]; >++ if (pid != xf->xf_pid) { >++ if (pid_found) { >++ return 0; >++ } else { >++ continue; >++ } >++ } >++ pid_found = 1; >++ if (0 > xf->xf_fd) >++ continue; >++ uret = func (udata, xf->xf_fd); >++ if (uret != 0) >++ break; >++ >++ } >++ >++ return 0; >++} >++#endif >++ >++static int >+ fdwalk (int (*cb)(void *data, int fd), void *data) >+ { >+ gint open_max; >+@@ -1086,6 +1139,12 @@ fdwalk (int (*cb)(void *data, int fd), void *data) >+ >+ #ifdef HAVE_SYS_RESOURCE_H >+ struct rlimit rl; >++#endif >++ >++#ifdef __FreeBSD__ >++ if (fdwalk2(cb, data, &res) == 0) >++ return res; >++ /* If any sysctl/malloc call fails continue with the fall back method */ >+ #endif >+ >+ #ifdef __linux__
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236815
:
205914
|
205931
|
205937
|
207442
|
207479
|
209087
|
218218