FreeBSD Bugzilla – Attachment 207480 Details for
Bug 240548
x11-toolkits/vte3: Loops over all possible file descriptors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
reworked
vte3.patch (text/plain), 2.63 KB, created by
Ivan Rozhuk
on 2019-09-14 02:02:02 UTC
(
hide
)
Description:
reworked
Filename:
MIME Type:
Creator:
Ivan Rozhuk
Created:
2019-09-14 02:02:02 UTC
Size:
2.63 KB
patch
obsolete
>Index: x11-toolkits/vte3/files/patch-src_vtespawn.cc >=================================================================== >--- x11-toolkits/vte3/files/patch-src_vtespawn.cc (nonexistent) >+++ x11-toolkits/vte3/files/patch-src_vtespawn.cc (working copy) >@@ -0,0 +1,99 @@ >+--- src/vtespawn.cc 2018-09-21 12:29:23.000000000 +0300 >++++ src/vtespawn.cc 2019-07-20 18:05:15.486558000 +0300 >+@@ -36,6 +36,12 @@ >+ #include <sys/resource.h> >+ #endif /* HAVE_SYS_RESOURCE_H */ >+ >++#ifdef __FreeBSD__ >++#include <sys/param.h> >++#include <sys/sysctl.h> >++#include <sys/user.h> >++#endif >++ >+ #include <glib-unix.h> >+ >+ #include "vtespawn.hh" >+@@ -410,7 +416,70 @@ >+ } >+ >+ #ifndef HAVE_FDWALK >++ >++#ifdef __FreeBSD__ >+ static int >++fdwalk2(int (*func)(void *, int), void *udata, int *ret) { >++ char *buf = NULL, *buf_end, *ptr; >++ size_t bufsz = 0, tmp = 0; >++ struct kinfo_file *kf; >++ int uret = 0; >++ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC, 0 }; >++ >++ if (func == NULL) >++ return EINVAL; >++ >++ /* Get files info. */ >++ mib[3] = (int) getpid (); >++ for (;;) { >++ if (0 != sysctl (mib, nitems(mib), NULL, &bufsz, NULL, 0)) { >++err_out: >++ free(buf); >++ return errno; >++ } >++ ptr = (char *) realloc (buf, bufsz); >++ if (ptr == NULL) >++ goto err_out; >++ buf = ptr; >++ if (sysctl (mib, nitems(mib), buf, &bufsz, NULL, 0) == 0) { >++ /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240573 >++ * If new files opened before next sysctl() call >++ * then kernel silently truncate result data. >++ * Re check required size to decrease chances >++ * to lost data. */ >++ if (sysctl (mib, nitems(mib), NULL, &tmp, NULL, 0) != 0) >++ goto err_out; >++ if (tmp > bufsz) >++ continue; /* More files opened, retry. */ >++ break; /* Ok. */ >++ } >++ if (errno != ENOMEM) >++ goto err_out;; >++ } >++ >++ /* Walk. */ >++ buf_end = (buf + bufsz); >++ for (ptr = buf; ptr < buf_end; ptr += kf->kf_structsize) { >++ kf = (struct kinfo_file *) (void *) ptr; >++ if (kf->kf_structsize == 0) >++ break; >++ if (kf->kf_fd < 0) >++ continue; >++ uret = func (udata, kf->kf_fd); >++ if (uret != 0) >++ break; >++ } >++ free (buf); >++ >++ if (ret != NULL) { >++ (*ret) = uret; >++ } >++ >++ return 0; >++} >++#endif >++ >++static int >+ fdwalk (int (*cb)(void *data, int fd), void *data) >+ { >+ gint open_max; >+@@ -419,6 +488,12 @@ >+ >+ #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 240548
:
207443
|
207480
|
218293