Bug #57791 Populating THR_thread_count through the new function
Submitted: 28 Oct 2010 7:12
Reporter: Bogdan Degtyariov Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S4 (Feature request)
Version: OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: my_thread_global_end, threading

[28 Oct 2010 7:12] Bogdan Degtyariov
Description:
ODBC test suite, which we currently use for our ODBC drivers need some reliable way to make sure that no error like this will occur upon calling my_thread_global_end():

Error in my_thread_global_end(): 10 threads didn't exit

The client library has an internal variable THR_thread_count used as thread counter in my_thr_init.c. The variable is not accessible outside the module, where it is declared. So, there is no way to determine the number of client library initializations.

How to repeat:
Create few threads in C API applications and do not call mysql_thread_end().

Suggested fix:
Populate THR_thread_count through a new function mysql_get_thread_count() or something like this....
[28 Oct 2010 7:19] Ulf Wendel
+1 on using a function and no magic access to public struct members. Structs always bite us whenever we discuss plugins that work with mysqlnd and C/C.