Hi,

2005/9/24, Lefteris Tsintjelis <[EMAIL PROTECTED]>:
> Sujay Koduri wrote:
>
> > I think mysql does not allow multiple threads to act on the same connection.
> > You have to create a connection pool and pick one for each thread
>

You can use one connection for all your thread.
Just be sure to properly enclose it with a lock/mutex, and build you
query thread-safe.

for connecting :
sql.lock
sql.connect
sql.unlock

for query :
sql.lock
mysql_thread_init()
sql.query
sql.sotre_result
mysql_thread_end()
unlock

> Either that or keep handling them on a per thread basis but do I have to also
> do mysql_server_init/end on a per child then, or just once in the parent proc?
>
> while loop childid
> {
>         fork();
>         ...
>         mysql_server_init(...);
>         mysql_real_connect(...)
>
>         ...handle thread...
>
>         mysql_close(...)
>         mysql_server_end();
>         ...
> }
> exit(0);
>
> or should it be something like:
>
> mysql_server_init(...);
> while loop childid
> {
>         fork();
>         ...
>         mysql_real_connect(...)
>
>         ...handle thread...
>
>         mysql_close(...)
>         ...
> }
> mysql_server_end();
> exit(0);
>
> Thnx,
>
> Lefteris
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>


--
Pooly
Webzine Rock : http://www.w-fenec.org/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to