You need to be very careful. Not just libdbi's own thread safety must be considered, but the thread safety of the drivers. In short, IMHO it is not possibly to correctly assume that a libdbi call, at least on the same connection handle, is thread safe. For example, this will always fail with MySQL. To the best of my knowledge libdbi does not use mutexes itself to avoid threading pitfalls on the driver layer (and I think this is a good design-decision, as most apps do not need these and they cost performance).
So your app must make sure that it calls into the drivers only in a thread safe way. In short: you must mutex-protect these cases yourself. As of my background: I am using libdibi in a rsyslog ( http://www.rsyslog.com ), a highly threaded, plugin-supporting syslogd. I had a lot of threading issues when writing the libdbi plugin for it ;) Rainer > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:libdbi-users- > [EMAIL PROTECTED] On Behalf Of Daniel Moreno > Sent: Thursday, June 26, 2008 11:44 PM > To: libdbi-users@lists.sourceforge.net > Subject: Re: [libdbi-users] Multithreading question > > As far as I now you should use the CVS version with the new functions: > > int dbi_initialize_r(const char *driverdir, dbi_inst *pInst); > void dbi_shutdown_r(dbi_inst Inst); > int dbi_set_verbosity_r(int verbosity, dbi_inst Inst); > dbi_driver dbi_driver_list_r(dbi_driver Current, dbi_inst Inst); > dbi_driver dbi_driver_open_r(const char *name, dbi_inst Inst); > dbi_conn dbi_conn_new_r(const char *name, dbi_inst Inst); > > replacing the old ones same name, without "_r". These should be thread > safe. > You also would need and additional parameter to "dbi_initialize_r" > declared as type "dbi_inst". > > Daniel.- > > > > On Thu, Jun 26, 2008 at 5:09 PM, AiFiLTr0 The GreAt > <[EMAIL PROTECTED]> wrote: > > > > > On Thursday 26 June 2008 22:07:09 you wrote: > > Hi, > > I've been working in a multithread server using libdbi against > postgre. > > My implementation use a connection per thread and is working > well for now, > > I'm doing testing yet. I had some problems before, but using > the cvs > > version with the "_r" functions works fine. > > I'm interested about libdbi and thread issues. > > > > Regards. > > Daniel. > > > > On Thu, Jun 26, 2008 at 2:59 PM, Claudiu CISMARU > <[EMAIL PROTECTED]> wrote: > > > > So the question is, is there anything that can be done with > > > > multithreading > > > > at this time? > > > > > > Create a mutex and lock it per connection. It will solve your > problem. > > > > > > > > > -- > > > Claudiu Nicolaie CISMARU > > > GNU GPG Key: http://claudiu.targujiu.net/claudiu.gpg > > > T: 0752095451, 0788358901 > > > E: [EMAIL PROTECTED], [EMAIL PROTECTED] > > > > > > ------------------------------------------------------------- > ------------ > > > Check out the new SourceForge.net Marketplace. > > > It's the best place to buy or sell services for > > > just about anything Open Source. > > > http://sourceforge.net/services/buy/index.php > > > _______________________________________________ > > > libdbi-users mailing list > > > libdbi-users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/libdbi-users > > > > Well, that's the actual thing I'm using, but I've just written a > pool to manage all the connections dynamically and keep their number > down, since not all the threads may require a database connection at > the same time. However, I'm not using th cvs version, therefore I'll > try it, Thanks for the tip. I'll post back later, once I've tested it. > > > > > > ----------------------------------------------------------------- > -------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > libdbi-users mailing list > libdbi-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libdbi-users > > > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ libdbi-users mailing list libdbi-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-users