|
From: Markus H. <mar...@mh...> - 2013-10-08 06:33:39
|
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
|