tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: getprotobyname -- thread local or _r?
On Sat, Aug 18, 2018 at 11:16:18PM +0000, Jay K wrote:
> Hi. This is probably an ancient topic and I didn't search the archives yet.
>
> A quick survey of operating system man pages says that in the vast majority of cases, either getprotobyname etc. returns data in a thread local, or getprotobyname_r, etc. are provided.
>
> getprotobyname uses thread local: OpenBSD, FreeBSD, NT, MacOSX.
> getprotobyname_r is provided: Linux, HP-UX, AIX, Solaris.
> Sometimes both: Tru64 (_r for compat, thread local for "real").
> No-op: Android?
>
> NetBSD seems to be the outlier here.
>
> Some people suggest to wrap one's own users in a lock, but this does not suffice. Everyone's uses within a process must be wrapped with the same lock. And not everyone can be coordinated to do so.
>
> Can this please be "fixed"?
POSIX doesn't require this function to be thread safe. So you can't
ever assume it will be. That said, it probably should be made thread-safe
in NetBSD. Could you just use getaddrinfo instead?
Jonathan Kollasch
Home |
Main Index |
Thread Index |
Old Index