Is inet_aton Thread-Safe? I know according to UNP that POSIX doesn’t require a lot of the Sockets API to be thread safe, and so I have to assume they’re not, but in general how do I know if something is thread safe in Perl? To what extent do I need to lock library function that I call? And how do I lock them? When I try something like lock(&inet_aton) it gives me an error: Can't modify non-lvalue subroutine call in lock.
And yes, I’ve read: Thread-Safety of System Libraries
If you read the
inet_atonmanpage carefully you will see that this call does not use any shared state (contrary to theinet_ntoafunction described in the same manpage), and thus should be thread safe.That the function writes its result into a caller-provided structure also supports this.
Perl uses a thin wrapper on top of those functions and thus doesn’t change the thread safety of the underlying library.