AW: Re: [AGENT++] AgentX++: Problem with destructor
alexander link
link.alexander at firemail.de
Wed Jun 2 09:25:27 CEST 2004
------- Ursprüngliche Nachricht -------
Von: alexander link <link.alexander at firemail.de>
Datum: Wed, 02 Jun 2004 07:21:57 GMT
Weiterleiten: AW: Re: [AGENT++] AgentX++: Problem with destructor
OK. Just if someone might have look.
Here is the subagent's most significant code:
#include "manyheaders.h"
#include "my_private_mib.h"
#ifdef AGENTPP_NAMESPACE
using namespace Agentpp;
#endif
u_short port; // communications port
SubAgentXMib* agentXMib;
AgentXRequestList* reqList;
boolean run = TRUE;
void init(SubAgentXMib& XMib)
{
XMib.add("", new my_private_mib("", &XMib));
.......
}
int main(int argc, char* argv[])
{
hServerInfoEvent = CreateEvent(0, FALSE, FALSE, "ServerInfoEvent");
agentXMib = new SubAgentXMib();
agentXMib->set_default_priority(100);
init_signals();
AgentXSlave* agentX = new AgentXSlave();
#ifdef AF_UNIX_SOCKET
agentX->set_unix_port_loc("/var/agentx/");
agentX->set_connect_mode(AX_USE_UNIX_SOCKET | AX_USE_TCP_SOCKET);
#else
agentX->set_connect_mode(AX_USE_TCP_SOCKET);
#endif
reqList = new AgentXRequestList(agentX);
//register requestlist for outgoing requests
agentXMib->set_request_list(reqList);
init(*agentXMib);
//module_init("", agentXMib);
agentXMib->init();
Vbx vb("1.3.6.1.6.3.1.1.5.1");
coldStartOid coldstart;
vb.set_value("subagent is starting");
agentXMib->notify("", coldstart, &vb, 1);
Request* req;
while(run && !agentXMib->get_agentx()->quit())
{
req = reqList->receive(20000);
if(req)
{
agentXMib->process_request(req);
}
else
{
agentXMib->ping_master();
}
}
delete agentXMib; //should invoke my_private_mib::~my_private_mib but does not
delete agentX;
return 0;
}
Any ideas???
Regards
Alex
------- Ursprüngliche Nachricht -------
Von:
Datum: Tue, 1 Jun 2004 19:48:01 +0200
Weiterleiten: Re: [AGENT++] AgentX++: Problem with destructor
Hi Alexander,
The destructor should have been called. May be something
else in your code removes the MIB object ungracefully?
Best regards,
Frank
alexander link schrieb am 01.06.2004,
13:37:00:
> Hi.
>
> I've got a problem with the destructor of my private added mib class. It seems that it is never called.
> The mib file is added in void init(SubAgentXMib& mib) and looks like this:
>
> mib.add("", new my_private_mib("", &mib));
>
> At the end of int main(int argc, char* argv[]) there is the statement
> delete SubagentXMib.
>
> So when I interrupt the while loop in the main routine with CTRL+C the above statement (delete
> SubagentXMib) is reached. My assumption was that this call would (also) invoke the destructor of
> my_private_mib. But this is not true, for I have verified it with the debugger.
>
> Because of additional thread cleaning purposes the destructor call is necessarily needed.
> Is there anything I can do or is there anything I haven't considered carefully?
>
> Regards Alexander
>
> _________________________________________________________________
> www.ebay.de Hier Finden Sie Auktionen und Festpreisangebote!
_________________________________________________________________
www.ebay.de Hier Finden Sie Auktionen und Festpreisangebote!
_________________________________________________________________
www.ebay.de Hier Finden Sie Auktionen und Festpreisangebote!
More information about the AGENTPP
mailing list