Il 05/11/2012 16:13, Giuseppe Modugno ha scritto:
I have written a scalar handler that takes up to 500ms to return. It
works for single GET requests. It is the same function for several OIDs.
If I send multiple GET requests (one request with 2 OIDs), it sometimes
doesn't work. To understand what could be the problem, I want to know if
the handler can be called the second time (for the second OID in the
request) even if the first call (for the first OID) hasn't returned yet.
Analyzing some debug messages, it seems this scenario is possible.
In the handler I communicate with a local socket with write(), select()
and read() standard functions. The select() has a timeout of 500ms and
the other end of the socket could take some time to answer (up to
500ms). I think snmpd could call again my handler for the second OID
during the select(). Is it correct?
In this case, even the second handler (the same code of the first) will
write to the socket. I'm asking if the two messages on the socket could
arrive corrupted.
For example, if the first message is "Message1" and the second is
"Message2", is it possible the other end of the socket receives an
overlapped messages, such as "MessMessage2age1"?
On the "Agent Architecture" page of Net-SNMP Wiki I read:
"Some requests can be processed in parallel. Although the Net-SNMP
agent is not thread-safe, it is capable of performing some tasks in
parallel. In particular, if a MIB module implementation indicates to
the main agent that it's "not yet done; please ask again later", the
agent will continue to receive packets and process them if it is
safe to do so. Typically, the MIB modules that support this
/delegated/ support are waiting for data to be returned from another
network, file handle or other socket.
It is not safe to process every type of request in parallel though.
In particular:
* PDUs safely parallel processed:
o GET
o GETNEXT
o GETBULK
* PDUs which must be processed serially:
o SET
For SNMP SETs, the agent finishes all outstanding requests and then
acts on the SETs that have arrived before continuing on to any other
requests in the queue."
It seems two different GET requests can be processed "at the same time"
if a MIB module implementation has to wait for some time to retrieve the
answer. In other words, the handler *must* return to the caller with the
message "not yet done; please ask again later". My handler doesn't
return, but wait for the answer for a timeout with a select() call, so I
think in this case the overlapping of requests aren't possibile.
Please, someone can confirm?
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders