[AGENT++] about callbacl function for notify reciver

Jochen Katz katz at agentpp.com
Fri Jan 12 21:19:57 CET 2007


Hi,

> when i develop my own callback function, what i have to be very very
> carefull about?   thanks.

pdu and target params are temporary objects/pointers, only use them
within the callback. If you want to pass them to another thread you have
to copy them.
The session pointer is valid until your application deletes it.
The data pointer (of async responses) has to be deleted by the callback,
as snmp++ doesn't know anything about it.

As the documentation states, you are not allowed to send any synchronous
snmp requests from within the callback function.

> in my current snmp_callback implemention, when my callback
> function(mCallback) called, i new a CNMS_TrapInnerMsg class object
> with two public data member pointer(Pdu*,SnmpTarget*), and then new a
> pdu object constructed with the pdu reference from mCallback params
> list,and then put the CNMS_TrapInnerMsg object in the queue of othere
> ACE_Task thread, and mCallback return.   CNMS_TrapInnerMsg object is
> deleted by ACE_Task thread after handling it. is it OK?

If I understand this right, your code is not ok, as you don't copy the
target object: depending on the target type you have to create a new
SnmpTarget, CTarget or UTarget object.

Regards,
  Jochen



More information about the AGENTPP mailing list