Hi, I'm writing code that should be run either as part of a snmp subagent or as a dynamically loadable module inside snmpd. The init_mymodule function, either called by the main fuction of the subagent or by snmpd upon loading, will have to register a bunch of handlers depending on configuration directives. The tutorial on loadable modules states that all registered handlers must be unregistered before module unloading to avoid unpleasantness like core dumps. Thus I made init_mymodule store the netsnmp_handler_registration * for each handler in a netsnmp_data_list using the handlerName as key. The freeing callback call netsnmp_unregister_handler on its argument and I have deinit_mymodule calling netsnmp_free_all_list_data. Apparently everything works... At least when I execute my code in a subagent (I have not yet tried to load the dynamically loadable module into snmpd, I'd rather prefer to be reasonably sure that everything works as expected before doing so). Then I thought that may be unregistering the handlers was not enough, what about data leak? Thus I tried to have the freeing callback calling netsnmp_handler_registration_free too. That was a bad idea, as now the subagent crashes when trying to call netsnmp_handler_registration_free on the first handler complaining that it tried to call free on some invalid pointer. The question is: it is enough to call netsnmp_unregister_handler to avoid memory leaks? A secondary question could be: do I have the right approach? :)
Thanks a lot for having read until here and for your help... -- Leo Cacciari Aliae nationes servitutem pati possunt. Populi romani est propria libertas ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users