This is a discussion on Memory leak in sub-agents within the SNMP Users forums, part of the Networking and Network Related category; Hi All, I am using net-snmp-5.1.2 in RH 9, i am using master sub-agent concept, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi All,
I am using net-snmp-5.1.2 in RH 9, i am using master sub-agent concept, whenever i am doing walk on a table memory used by the sub-agent keeps on growing. I used mib2c to generate the skeleton code. mib2c.iterate.conf Below is the code which i modified to suit our need. Is there anything wrong with the modification. or any API available to free the memory. void initialize_table_channelTable(void) { static oid channelTable_oid[] = { x, x, x, x, x, x, x, x, x }; netsnmp_table_registration_info *table_info; netsnmp_handler_registration *my_handler; netsnmp_iterator_info *iinfo; /** create the table registration information structures */ table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_inf o); /** if your table is read only, it's easiest to change the HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY */ my_handler = netsnmp_create_handler_registration("channelTable" , channelTable_handler, channelTable_oid, OID_LENGTH (channelTable_oid), HANDLER_CAN_RWRITE); if (!my_handler || !table_info ) { snmp_log(LOG_ERR, "malloc failed in initialize_table_channelTable"); return; /* Serious error. */ } netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: channelId */ 0); table_info->min_column = 1; table_info->max_column = 7; DEBUGMSGTL(("initialize_table_channelTable", "Registering table channelTable as a table iterator\n")); netsnmp_register_table_iterator(my_handler, table_info); } void init_ioCardGroup(void) { /** here we initialize all the tables we're planning on supporting */ initialize_table_channelTable(); } /** handles requests for the channelTable table, if anything else needs to be done */ int channelTable_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { netsnmp_request_info *request; netsnmp_table_request_info *table_info; netsnmp_variable_list *var; for (request = requests; request; request = request->next) { var = request->requestvb; if (request->processed != 0) continue; /** extracts the information about the table from the request */ table_info = netsnmp_extract_table_info(request); if (table_info == NULL) { continue; } switch (reqinfo->mode) { case MODE_GET: switch (table_info->colnum) { case COLUMN_CHANNELID: snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *) /** XXX: column data */ , /** XXX: column data length */ ); break; case COLUMN_CHANNELNAME: snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) /** XXX: column data */ , /** XXX: column data length */ ); break; default: /** We shouldn't get here */ snmp_log(LOG_ERR, "problem encountered in channelTable_handler: unknown column\n"); } break; case MODE_SET_RESERVE1: /** set handling... */ default: snmp_log(LOG_ERR, "problem encountered in channelTable_handler: unsupported mode\n"); } } return SNMP_ERR_NOERROR; } -- Regards, Sasikumar.B ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ 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/...net-snmp-users |