Re: Should my set handler be hit multiple times?

Wes Hardaker <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Andrew Agno <[email protected]> writes:

> In particular, having my code log whenever MODE_SET_COMMIT is called, I see that it gets called twice.  Is this
> expected behavior?  The FAQ mentions this can happen with get next/first, but not on setting a value.
>
> One thing that I have noticed is that I can only reproduce this if I have an event loop that pauses for a long time
> (using sleep(1), for example):
>
>   while(keep_running) {
>     while(agent_check_and_process(0) > 0) ; // need to call this in a loop or things don't work
>     sleep(1);
>   }

The sleep will certainly cause issues because the manager likely has a
timeout set to retry sending a request.  And if it times out while
you're sleeping the manager will send a second SET request.  This can be
verified by using the -d switch, which dumps packets being sent.

The better way to do that loop is:

    while(keep_running) {
      agent_check_and_process(1);
    }

Setting the argument 1 to agent_check_and_process will cause it to block
and wait for packets, so you shouldn't need a sleep.

-- 
Wes Hardaker
Parsons

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.