Bug #59114 The handles are not closed
Submitted: 22 Dec 2010 17:27 Modified: 22 Aug 2013 7:38
Reporter: Andrey Spurs Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.0.5, 1.1.0 OS:Windows (XP)
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[22 Dec 2010 17:27] Andrey Spurs
Description:
MySQL Connector/C++ (mysqlcppconn) was compiled using CMAKE and MSVS 2008

Problem:
when i am using connect method and close method all handles are closed successfully.
when i am using connect method in the separate thread and then close method 3 handles are not closed.

How to repeat:
#include <windows.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>

sql::Driver		*driver;
sql::Connection		*con;
HANDLE			h;

void my_connect()
{
driver = get_driver_instance();
con = NULL;
try
{
// assumed that connection is OK.
con = driver->connect("localhost", "user", "user");
con->setSchema("db");
}
catch(sql::SQLException &e)
{
}
}

void my_connect_close()
{
try
{
if(con != NULL)
{
con->close();
delete con;
}
}
catch(sql::SQLException &e)
{
}
}

UINT ThreadCon(void *p)
{
my_connect();
CloseHandle(h);
h = NULL;
ExitThread(0);
return 0;
}

void my_connect_thr()
{
h = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(void*)ThreadCon, 0, 0, NULL);
}

int _tmain(int argc, _TCHAR* argv[])
{
	Sleep(5000);

	my_connect();		// makes 3 handles, delete 3 handles
	my_connect_thr();	// makes 6 handles, delete 3 handles

	Sleep(5000);

	my_connect_close();

	Sleep(5000);

	return 0;
}
[28 Dec 2010 9:54] Andrey Spurs
for Connector/C++ 1.1.0 the problem is the same
[20 Jun 2013 9:30] Bogdan Degtyariov
Thank you for reporting a problem in MySQL software and for providing the test case.
Sorry for the delay with processing this bug.
I have just started monitoring reports for Connector/C++, so things will go much faster from now.

In order to proceed with the bug fixing I need to get some additional information
The term "handle" in the context of the description you gave sounds a bit ambiguous. Unfortunately, the C++ test case does not indicate or measure the number of handles. Can you explain what handles are not closed? Are they the connection handles or general windows handles or something else? How did you measure their number? Did you use the ProcessExplorer?

Please note that the application and Connector/C++ does not have the full control over all handles as some of them used and managed by the system and the runtime libraries.

Thanks.
[21 Jul 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[22 Jul 2013 7:38] Bogdan Degtyariov
Hi Andrey,

This bug has been waiting on your feedback for some time.
Do you have any updates?
Thanks.
[23 Aug 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".