From: Dave S. <D.T...@cs...> - 2003-06-18 09:14:37
|
> In implementing iterators for my agent, I'm making a copy of the > data to return to the master agent and putting it in a temporary > buffer that gets freed the next time it gets called. Unfortunately > it seems that the net-snmp agent code wants to use "old" pointers, > at some point and the app dies. > > How long do I need to keep pointers returned from first & next > row enumerators valid for ? Until the handler routine is called. > I would have thought that if it is going to visit each cell, > one at a time, then when you get to the next one, it's an indication > that information used for the prior one is finished with... But remember that the get_{first,next}_data_entry routines are just concerned with determining *which* row is needed. So the agent will zoom through all of them, and only gets as far as calling the handler routine (i.e. using the data you've set up) when it's run off the end. These iteration routines do *NOT* correspond to individual SNMP requests. (Sorry if this is old news, but it confused me greatly until I twigged it!) I haven't checked the latest version of the table iterator driving code, but the released versions include two other hooks that might be relevant: make_data_context which copies the data for a given row (Though I think there might be a bug in this. Around line 296, surely it should pass 'callback_data_context', not 'callback_loop_context'?) free_data_context which frees the data for a given row Oh, don't be lazy Dave - <tap, tap, tap> - yup, the rewrite still has these two hooks. (And the same possible bug in calling make_data_context. Care to comment, Wes?) Dave |