On Thu, 2005-06-16 at 19:13, gg gg wrote:
> I am trying to understand the purpose of a portion of
> code in agent_registry.c/netsnmp_subtree_load. The
> code was submitted in version 5.25.2.1.
Actually, that particular section of code was submitted
as part of revision 5.20:
"fix context registration so new context
trees get properly initialized"
> inloop = 1;
> netsnmp_register_null_context....);
> netsnmp_register_null_context....);
> netsnmp_register_null_context....);
> inloop = 0;
> Can you explain the purpose of this code? Can you
> explain why inloop is set to 0 after being set to 1?
Look what happens in between these two assignments.
There are those three calls to 'netsnmp_register_null_context'
If you follow through the code from that routine, you'll find
that this eventually ends up calling netsnmp_subtree_load
again.
So 'ns_subtree_load()' calls 'ns_register_null_context()'
which calls 'ns_subtree_load()'
which calls 'ns_register_null_context()'
which calls 'ns_subtree_load()'
which calls 'ns_register_null_context()'
etc, etc, etc
The 'inloop' flag is used to break this infinite loop.
The first invocation of 'ns_subtree_load()' sets this
to indicate that it's handling these three registrations.
The second invocation of 'ns_subtree_load()' recognises
that this is what's happening, so doesn't leaves things
for the first version to deal with.
> It would seem like there is a bug here or some extraneous code.
Nope. It's correct, and necessary.
Dave
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders