I use a few threads, each of them is supposed to have its own MySQL connection. I call Connector::registerConnector in the main thread and then create a session in each thread (to be precise new Session is called from a different pthread). Registering the connector as well as creating sessions inits new threads with mysql (my_thread_init()), so with say 4 worker threads I have 5 calls to my_thread_init(). Threads close their sessions themselves as they finish their jobs but calling Session.close doesn't seem to invoke my_thread_end() so when I finally call Connector::Unregister I get an error: my_thread_global_end(): 4 threads didn't exit.
How should I properly close the sessions so that the treads are ended in libmysqlclient ? mysql_close() called from SessionHandle doesn't seem to end the thread from mysql point of view and that leads to memory leaks.