On Mon, May 24, 2010 at 5:46 PM, Wes Hardaker < [email protected]> wrote:
> >>>>> On Mon, 24 May 2010 14:08:02 +0200, Bart Van Assche < > [email protected]> said: > > BVA> The patch below fixes the circular dependency between > libnetsnmphelpers and > BVA> libnetsnmpagent. > > That one call is the only dependency? (which surprises me in itself). > All other dependencies should have been addressed by r18829. Sigh... If we go that route it certainly warrants and important > "release notes" note because it'll possibly be the first time we've ever > made such a huge requirement change from anyone implementing an external > agent. An alternative is the patch below. init_agent() still calls netsnmp_init_helpers(), but only if libnetsnmphelpers.so has been loaded before libnetsnmpagent.so. This has been realized by adding a shared-library initialization function in libnetsnmphelpers.so. Such constructors are supported on all platforms that support creating C++ shared libraries. I'm not sure though that the syntax __attribute__((constructor)) is also supported by non-gcc compilers -- some porting may be necessary. Bart. Index: include/net-snmp/agent/snmp_vars.h =================================================================== --- include/net-snmp/agent/snmp_vars.h (revision 18834) +++ include/net-snmp/agent/snmp_vars.h (working copy) @@ -93,6 +93,8 @@ oid name[MAX_OID_LEN]; /* object identifier of variable */ }; + NETSNMP_IMPORT void (*netsnmp_init_helpers_p)(void); + int init_agent(const char *); void shutdown_agent(void); Index: agent/snmp_vars.c =================================================================== --- agent/snmp_vars.c (revision 18834) +++ agent/snmp_vars.c (working copy) @@ -155,6 +155,8 @@ struct module_init_list *initlist = NULL; struct module_init_list *noinitlist = NULL; +void (*netsnmp_init_helpers_p)(void); + /* * mib clients are passed a pointer to a oid buffer. Some mib clients * * (namely, those first noticed in mibII/vacm.c) modify this oid buffer @@ -296,7 +298,8 @@ _init_agent_callback_transport(); - netsnmp_init_helpers(); + if (netsnmp_init_helpers_p) + (*netsnmp_init_helpers_p)(); init_traps(); netsnmp_container_init_list(); init_agent_sysORTable(); Index: agent/helpers/all_helpers.c =================================================================== --- agent/helpers/all_helpers.c (revision 18834) +++ agent/helpers/all_helpers.c (working copy) @@ -12,6 +12,18 @@ #include <net-snmp/agent/table_dataset.h> #include <net-snmp/agent/stash_cache.h> + +/** + * Shared-library constructor function that makes sure that init_agent() + * will call netsnmp_init_helpers() if libnetsnmphelpers.so is loaded + * before libnetsnmpagent.so is loaded. + */ +static void __attribute__((constructor)) netsnmp_libnetsnmphelpers_init(void) +{ + netsnmp_init_helpers_p = &netsnmp_init_helpers; +} + + /** call the initialization sequence for all handlers with init_ routines. */ void netsnmp_init_helpers(void)
------------------------------------------------------------------------------
_______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
