1 Aug 2002 13:35
using my_thread_* in a library
Guillaume Morin <guillaume <at> morinfr.org>
2002-08-01 11:35:38 GMT
2002-08-01 11:35:38 GMT
Hi folks, I am the maintainer of NSS MySQL which is, as you may have guessed, a nss module using MySQL as backend. It shares a mysql connection between threads. As explained in the documentation, I use my_thread_init and my_thread_end functions to properly manage that situation. As you may know, a nss module provides UNIX user lookup functions such as getgrnam. That means that basically any applications can call the nss modules function even the ones which uses MySQL too. And there lies the issue. Indeed, if the application follows this path : - calls mysql_connect or mysql_thread_init ... - calls a function like getgrnam - does MySQL stuff The application will segfault since the nss module has called my_thread_end. I do not see any solutions to this because if I remove calls to my_thread_end I create a memory leak. I've read the source of my_thread_init, it seems that there is no way to know if the MySQL data was already allocated (in this case, I would not call my_thread_end). Does anyone have an idea ? Maybe, my_thread_init should be modified to return a special error code if the MySQL data was already allocated... TIA. PS: sorry if it is the wrong list, I already tried to ask on the general list and got no answer.(Continue reading)
RSS Feed