|
From: Ethan F. <et...@re...> - 2013-10-08 05:10:31
|
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...@re... _______________________________ 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; } |