[AGENT++] Thread handle leak (SNMP++ 3.2.21a)

Jochen Katz katz at agentpp.com
Tue Jan 16 23:31:38 CET 2007


Hi,

> SNMP++ seems to cause handle leakage under Win32 because the thread
> handle m_hThread that is assigned inside Snmp::start_poll_thread() is
> not closed via a call to CloseHandle() in Snmp::stop_poll_thread().
> 
> Could you, please, confirm this one and eventually give some info
> when it could get patched?

it can be patched immediately ;-)

Just change stop_poll_thread() to;
#ifdef WIN32
    ::WaitForSingleObject(m_hThread, INFINITE);
    CloseHandle(m_hThread);
#elif defined (CPU) && CPU == PPC603

This will be in the next release.

A funny thing: If you don't need the handle after the thread is started,
you can write code like this:
CloseHandle(CreateThread(NULL,0, ThreadA,NULL,0,NULL));


Regards,
  Jochen



More information about the AGENTPP mailing list