[AGENT++] uxsnmp

Frank Fock fock at agentpp.com
Wed May 13 00:09:14 CEST 2015


Hi Richard,

Wouldn't it be better to have a callback when the thread ended and then 
unload the DLL.
Your workaround might be working but I do not see a reason why that 
should prevent a crash
for sure. A race condition may still occur, doesn't it?

Best regards,
Frank

Am 07.05.2015 um 17:05 schrieb Straus, Richard:
> Hi,
>
> We have encountered a crash in the Snmp::stop_poll_thread() call. This crash includes the latest version of snmp++ 3.3.5.
>
> We have determined the issue to be caused by WaitForSingleObject call:
>
> #ifdef WIN32
>      ::WaitForSingleObject(m_hThreadEndEvent, INFINITE);
>      CloseHandle(m_hThread);
>
> The SNMP calls are made in a DLL that is loaded and then unloaded. The problem is the thread keeps running for a brief period of time after setting m_hThreadEndEvent and during that time, the DLL unload sometimes completes - taking away the object code from the still-executing thread.
>
> We have been able to resolve the issue for WIN32 by removing all code referring to m_hThreadEndEvent. That means deleting the CreateEvent, SetEvent, ResetEvent calls pertaining to m_hThreadEndEvent as they are unnecessary. The above code in stop_poll_thread() is then replaced with this code:
>
> #ifdef WIN32
>                  if (NULL != m_hThread && INVALID_HANDLE_VALUE != m_hThread)
>                  {
>                                  ::WaitForSingleObject(m_hThread, INFINITE);
>                                  CloseHandle(m_hThread);
>                                  m_hThread = NULL;
>                  }
>
> Regards
>
> Richard Straus
> Senior Software Developer
> Equitrac MFP and Print Management Solutions
> Nuance Communications
>
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> https://oosnmp.net/mailman/listinfo/agentpp

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the AGENTPP mailing list