[AGENT++] Using agent++ with multithreading in a MFC application
Florica Moldoveanu
Florica.Moldoveanu at rdslink.ro
Fri Jan 5 11:52:58 CET 2007
Hello
I tried to build a manager-agent pair of applications using MFC ( with
Microsoft Visual Studio 2005)and snmp++ v3.2 - agent++ v3.5. I included
#define _NO_SNMPv3
#define _NO_LOGGING
in both agent++.h and config_snmp_pp.h.
The best place (and the only normal one) to put the receive() call in an MFC
application is the OnIdle() overriden function. So, I included it in the
following way:
BOOL CagentApp::OnIdle(long lCount)
{
BOOL bMore = CWinApp::OnIdle(lCount);
Request * req=reqList->receive(0);
if (req)
mib->process_request(req); // process the request
return true;
}
The manager application send a get() request. The agent crashes to
threadPool->execute(mt) with the error: Unhandled exception at 0x10029503
(agent_pp.dll) in agent.exe: 0xC0000005: Access violation reading location
0x00000000.
void Mib::process_request(Request* req)
{
#ifdef _THREADS
MibMethodCall* call = new MibMethodCall(this,
&Mib::do_process_request, req);
#ifdef AGENTPP_USE_THREAD_POOL
MibTask* mt = new MibTask(call);
------>>> threadPool->execute(mt);
#else
#ifdef _WIN32THREADS
If I compile snmp++ and agent++ with
#define _NO_THREADS
then the two programs work properly. The problem is that in this way I
cannot use the asychronous functions in the manager application and probably
cannot receive traps or informs.
I tried also to include the receive() call in a callback Timer function. The
agent crashes in the same point but without an error message!
Al the projects and libraries were built with the same setting:
SNMP_PP_NATIVE_EXPORTS
AGENT_PP_NATIVE_EXPORTS
Multi-threaded DLL (/MD).
Can you help me with an advise?? Is this problem already known?? I had a
look on the AgetPP archives but I didn't find an answer.
Thank you in advance,
Professor Florica Moldoveanu
More information about the AGENTPP
mailing list