Brendan Shanks (@bshanks) commented about dlls/nsiproxy.sys/udp.c:
}
#elif defined(HAVE_SYS_SYSCTL_H) && defined(UDPCTL_PCBLIST) && defined(HAVE_STRUCT_XINPGEN) {
int mib[] = { CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_PCBLIST }; size_t len = 0; char *buf = NULL; struct xinpgen *xig, *orig_xig;
if (sysctl( mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0 ) < 0)
+#ifdef __APPLE__
static int mib[CTL_MAXNAME];
static size_t mib_len = 0;
if (mib_len == 0)
{
mib_len = CTL_MAXNAME;
I'm not sure how likely it is, but if the first thread has set mib_len but sysctlnametomib() hasn't returned yet, another thread would call sysctl() with an invalid/empty mib. Maybe use dispatch_once() or pthread_once() to fill the cache? Or don't cache at all?