Yes, this seems sufficient if you note that dbi-connect also needs protection as the libdbi code maintains a connection linked list that is not thread safe with out a mutex.
In my code, even with the reentrant version of the mysqlclient library linked against the driver, I still use a single mutex around the functions you mentioned and dbi-connect. Using libmysqlclient_r resolved the "MySQL server has gone away" errors and random crashes that back trace to the libmysqlclient library when I had multiple threads running queries. Ethan... On Sep 2, 2010, at 3:32 PM, Markus Hoenicka wrote: > Kjell Irgens writes: >> I notice now that my dbi_conn_error() is also protected with the same >> scoped mutex as dbi_conn_query(). >> >> I use the same connection in several threads without this causing any >> problems (apart from having to use the mutex). >> > > Hi, > > I've added the following section to the docs: > > --8<--- > Using libdbi in multithreaded applications > > With some precautions, libdbi can be used in multithreaded > applications. One way to do this is to initialize separate libdbi > instances in each thread. If this is not an option and several threads > have to share a single instance, you currently need to protect certain > libdbi function calls with mutexes. These functions are > dbi-conn-query, dbi-conn-ping, and dbi-conn-error. > --8<--- > > Emmanuel, Kjell, Ethan: with your experience in running multithreaded > libdbi apps, do you think this section is appropriate and sufficient? > > regards, > Markus > > -- > Markus Hoenicka > http://www.mhoenicka.de > AQ score 38 > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Libdbi-drivers-devel mailing list > Libdbi-drivers-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Libdbi-drivers-devel mailing list Libdbi-drivers-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel