Subject: getaddrinfo() vs. JVM
To: None <tech-userlevel@netbsd.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-userlevel
Date: 01/07/2005 21:05:59
I just had another interesting crash in the JVM.  This time, it was because 
the JVM expects getaddrinfo() to be reentrant, but ours is not -- it tunnels 
down into getservbyname(), which uses a global servent_data structure and 
doesn't do any locking.

What's the suggested way to fix this?  As I see it, we could:

1) Create thread-specific data.  This is going to be a bit slower, and will 
prevent sharing the file descriptor, among other things.

2) Put a mutex around getservbyname() and/or getaddrinfo().  Is there a way to 
do this in libc that will work both with and without libpthread?