Hi,
Thanx for responding.
Only one worker thread was accesing MYSQL* myHdl. Nevertherless i have placed mutexes
around all calls involing MYSQL*.
main-thread: Defined MYSQL* myHdl as global variable and called mysql_init(), and
mysql_connect();
worker: Defined MYSQL_RES* res and used myHdl to query with no problems. Crashes upon
mysql_num_res or mysql_fetch_rows.
gdb gives:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3076 (LWP 23491)]
0x400519e3 in mysql_fetch_row () from /usr/lib/libmysqlclient_r.so.10
(gdb) bt
#0 0x400519e3 in mysql_fetch_row () from /usr/lib/libmysqlclient_r.so.10
#1 0x08054d40 in th_connection ()
#2 0x40036fef in pthread_start_thread () from /lib/i686/libpthread.so.0
#3 0x400370df in pthread_start_thread_event () from /lib/i686/libpthread.so.0
-Original Message-
From: Eric Bergen [EMAIL PROTECTED]
To: darren [EMAIL PROTECTED]
Date: Wed, 30 Jun 2004 20:06:40 -0500
Subject: Re: threading problems in linux C client
If you have multiple threads accessing the same connection remember to
make sure that only one thread enters mysql_query() mysql_connect() or
mysql_store_result() after you store the result another thread will be
able to use that connection without problems.
-Eric
On Wed, 30 Jun 2004 11:01:35 +, darren [EMAIL PROTECTED] wrote:
Hi all,
I am writing a multi-threaded client that requires shared access to a single MySQL
connection. The environment is Redhat 7.3 with the patched
mysql-3.23.58-2.71.i386.rpm installed and compiled with -l libmysqlclient_r.
The connection is made from the main thread and a MYSQL_RES* myres declared from the
child thread is used to fetch results back to the thread. I get a Segmentation fault
the first instance my child thread (only one) accesses MYSQL_RES through
mysql_num_rows(myres). (gdb informed me that this is due to mysql_num_rows from
libmysqlclient_r.so.10)
I have read a few docs about writing MySQL multi-threaded clients and have called
my_init() in my main prog and my_thread_init() at the first line of my thread
handler.
Any ideas?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]