[AGENT++] Multi threaded Process: Dedicated thread for snmp trap

Jochen Katz katz at agentpp.com
Tue Jan 20 22:37:08 CET 2009


Hello,

> Is it possible create a dedicated thread to receive snmp traps in a
> multi threaded process ?

not if you only have one Snmp object. If you use a dedicated Snmp object
for receiving traps, you can do this.

> Looking at the source of snmp++ 3.2.23 this does not seem possible
> even if we use the Snmp::start_poll_thread as the 
> SNMPBlockForResponse (called during get operations from
> Snmp::snmp_engine) function also calls SNMPProcessEvents ->
> SNMPProcessPendingEvents that would cause the registered trap
> callback function to be called during synchronous snmp gets.

Yes. Both, the poll thread and snc requests, us the same functions to
receive data from all sockets and trigger processing. Therefore, if you
send a sync request in a thread, this thread can call the callback
functions for incoming traps or incoming async responses.

> We are
> seeing this behaviour where our snmp get/walk threads are being
> stepped on by trap callbacks potenitally deadlocking ?

You will only get a deadlock, if you send sync requests from within a
callback.

> Please advice correct use to ensure dedicated or single purpose
> callback thread for trap reception in a multi threaded process where
> other threads are to be used for snmp get operations only.

You will have to use multiple Snmp objects to achieve this.

Regards,
  Jochen



More information about the AGENTPP mailing list