[Date Prev][Date Next] [Chronological] [Thread] [Top]

Separate mutexes for gethostbyname/addr



The socket routines gethostbyname() and gethostbyaddr() return a pointer to a hostent structure.  In some systems this is a static variable and is not thread-safe.  The current OpenLDAP development code defines a different mutex for each of these calls to provide synchronization.

For systems that need this synchronization, this framework assumes that gethostbyname and gethostbyaddr use different static structures to return this data.  In my system, and perhaps in many or most others, there is a single static hostent structure used by both of these routines.  Therefore having two separate mutexes doesn't provide the necessary synchronization.

I suggest that they be combined into one mutex.  This will still work on systems that provide separate static structures for each call, with perhaps only slightly coarser locking.