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.

Thanks,

Ethan Funk
970-325-2158 x11
et...@redmountainradio.com

_______________________________
Red Mountain Radio LLC
PO Box 1058
331 Six Avenue #3
Ouray, CO 81427
http://www.redmountainradio.com


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;
}




------------------------------------------------------------------------------
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