> For example, have you called mysql_thread_init() before calling
> mysql_real_connect() in all your threads ?

However, to my understanding, mysql_thread_init() is not needed if
only one database connection is used, and that database connection
is established when the program starts, before any threads have been
created.  That is, if you call mysql_real_connect() at the top
of main(), for example, and you let the connection persist for the
lifetime of the program, then mysql_thread_init() is not necessary,
and the only thing that you must worry about is to make sure that
critical sections (like between mysql_real_query() and 
mysql_store_result()) are sandwiched in-between a mutex lock.

If the above is incorrect, please let me know.


Michael



On Fri, 26 Apr 2002, Michael Widenius wrote:

> 
> Hi!
> 
> >>>>> "Andrey" == Andrey Kotrekhov <[EMAIL PROTECTED]> writes:
> 
> <cut>
> 
> Andrey> #12 0x180e7cdc in mysql_real_connect ()
> Andrey>    from /usr/local/mysql/lib/libmysqlclient.so.10
> Andrey> #13 0x1812f93c in MysqlConnection::real_connect (this=0x80c9c18,
> Andrey>     db=0x80fe8b0 "zzz", host=0x80fb040 "xxx.xxx.xxx",
> Andrey>     user=0x80fe910 "xxx", passwd=0x80c26aa "", port=3306, compress=1,
> Andrey>     connect_timeout=60, socket_name=0x80c26be "", client_flag=0)
> Andrey>     at connection.cc:52
> Andrey> #14 0x808384f in QueueModule::Run (this=0x80c9c00) at QModule.cc:166
> Andrey> #15 0x8068a8b in start_Module (ptr=0x80c9c00) at Module.cc:23
> Andrey> #16 0x181fce73 in _thread_start () from /usr/lib/libc_r.so.4
> Andrey> #17 0x0 in ?? ()
> 
> Andrey> Under FreeBSD gethostbyname is not thread-safe
> Andrey> And there is no thread-safe gethostbyname_r
> Andrey> (function exist but not thread-safe)
> 
> Andrey> Are mysql know about this!!!
> 
> Sorry but if your OS doesn't support gethostbyname_r(), then
> mysql_real_connect() is not thread safe (I have just updated our
> documentation about this)
> 
> Another issue is that if your client dies in the dbug_ code, this
> means that you have probably not followed the instructions in the
> manual section:
> 
> 'How to Make a Threaded Client'
> 
> For example, have you called mysql_thread_init() before calling
> mysql_real_connect() in all your threads ?
> 
> Regards,
> Monty
> 
> 

-- 
/*--------------------------------------------------------------------------
* "It might look like I'm doing nothing, but at the cellular level
* I'm really quite busy."
*  ---anonymous
*
*
* -----BEGIN GEEK CODE BLOCK-----
* Version: 3.1
* GCS/P/H/L/O d- s-:-- a26 C++(+++) UL+++$>++++ P++ L+++ !E W+++ N- o? K-
* w--(---) !O M+ !V PS+ PE- Y-- PGP- t+ 5-(--) X(-) R* tv b+ DI-- D-- G e+>++
* h+ r* y--
* ------END GEEK CODE BLOCK------
--------------------------------------------------------------------------*/


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to