Am 2013-10-08 06:54, schrieb Ethan Funk: 

> I would like to recommend the following code change to the 0.9 mysql driver 
> code to prevent a memory leak when the driver is linked against the 
> thread-safe mysqlclient_r library. The if(mysql_thread_safe()) statement 
> should ensure that the mysql cleanup function I added for threads is not 
> invoked if the driver is linked against the non-reentrant mysqlclient 
> library. The MySQL documentation indicates that "mysql_thread_init() is 
> automatically called by my_init(), which itself is automatically called by 
> mysql_init(), mysql_library_init(),mysql_server_init(), and mysql_connect(). 
> If you invoke any of those functions,mysql_thread_init() will be called for 
> you." So all that is missing is the mysql_thread_end call. 
> 
> If each thread has it's own connection, and libdbi instance, as recommended 
> by the libdbi documentation, this should work transparently.
> 
> [...]

> int dbd_disconnect(dbi_conn_t *conn) { 
> if (conn->connection) { 
> mysql_close((MYSQL *)conn->connection); 
> // added to resolve memory leak in threadsafe mysqlclient library: assume 
> each thread has it's own connection 
> if(mysql_thread_safe()) 
> mysql_thread_end(); 
> } 
> return 0; 
> }

Hi, 

this sounds reasonable as long as everyone sticks to the
recommendations. I'll ask the other way round: is there anyone out there
who insists on sharing connections between threads? 

regards, 

Markus 

-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38

 
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel

Reply via email to