Motivation:
I'm using the net-snmp library as part of a bigger project. The software is multi-threaded, so we use "--enable-reentrant" when configuring net-snmp. Unfortunately, this leads to lockups in some situations: the library "hangs" when locking a pthread mutex (on Linux). After some debugging I found out that the library tries to lock the same mutex twice.
The pthread mutexes are initialized using the "default mutex attributes" (that's what the manpage of pthread_mutex_init says), and trying to lock those more than once results in undefined behaviour (according to the manpage for pthread_mutex_lock).
I created a patch against net-snmp-5.7.1 to fix the mutex initialization, so that they have the type PTHREAD_MUTEX_RECURSIVE. I shortly tested it under Linux (Redhat and Debian) as well as Solaris. Feedback is welcome :)
Thanks for the patch! It has been applied to the 5.4.x and above code branches and the main development tree, and will appear in future releases of the Net-SNMP package.