On Tue Jul 9 19:37:37 2024 +0000, Tim Clem wrote:
Ah, good call. Breaking things out into a separate function for pthread_once would be verbose. What if I just stop having `mib_len` do double-duty and do something like this?
static int mib[CTL_MAXNAME], inited = 0; static size_t mib_len = CTL_MAXNAME; if (!inited) { sysctlnametomib( "net.inet.tcp.pcblist64", mib, &mib_len ); inited = 1; }
Then the worst case is an extra call to `sysctlnametomib`.
Yeah that's better. I guess it's still possible that one thread could be inside sysctlnametomib() and writing to mib while another one is trying to call sysctl() for it, but that seems pretty remote.