I add some code to free memory that isn’t being cleaned up when snmp is shutdown.  The code is pretty simple, I added a function to lcd_time.c called free_etimelist which iterates through the list of Enginetime structures and frees the memory.  I added a call to free_etimelist to snmp_shutdown.  I also added a call to clear_user_list to snmp_shutdown so that the memory allocated for usm users is freed at shutdown.

 

Let me know what you think.

 

Index: lcd_time.h

===================================================================

RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/library/lcd_time.h,v

retrieving revision 5.1

diff -p -u -r5.1 lcd_time.h

--- lcd_time.h    2 Jul 2003 20:20:56 -0000     5.1

+++ lcd_time.h    7 Jul 2006 19:31:13 -0000

@@ -128,6 +128,7 @@ extern          "C" {

 

     void            dump_etimelist_entry(Enginetime e, int count);

     void            dump_etimelist(void);

+     void              free_etimelist(void);

     void            free_enginetime(unsigned char *engineID, size_t engineID_len);

 

 #ifdef __cplusplus

 

 

Index: lcd_time.c

===================================================================

RCS file: /cvsroot/net-snmp/net-snmp/snmplib/lcd_time.c,v

retrieving revision 5.3

diff -p -u -r5.3 lcd_time.c

--- lcd_time.c    2 Oct 2004 03:51:07 -0000     5.3

+++ lcd_time.c    7 Jul 2006 19:50:05 -0000

@@ -278,7 +278,42 @@ void free_enginetime(unsigned char *engi

 

 }

 

+/*******************************************************************-o-******

+ * free_etimelist

+ *

+ * Parameters:

+ *   None

+ *     

+ * Returns:

+ *   void

+ *

+ *

+ * Free all of the memory used by entries in the etimelist.

+ *

+ */

+void free_etimelist(void)

+{

+     int index = 0;

+     Enginetime e = 0;

+     Enginetime nextE = 0;

+

+     for( ; index < ETIMELIST_SIZE; ++index)

+     {

+           e = etimelist[index];

+

+           while(e != 0)

+           {

+                 nextE = e->next;

+                 SNMP_FREE(e->engineID);

+                 SNMP_FREE(e);

+                 e = nextE;

+           }

+

+           etimelist[index] = 0;

+     }

 

+     return;

+}

 

 /*******************************************************************-o-******

  * set_enginetime

 

 

Index: snmp_api.c

===================================================================

RCS file: /cvsroot/net-snmp/net-snmp/snmplib/snmp_api.c,v

retrieving revision 5.102

diff -p -u -r5.102 snmp_api.c

--- snmp_api.c    5 Jul 2006 21:44:24 -0000     5.102

+++ snmp_api.c    7 Jul 2006 19:32:53 -0000

@@ -877,6 +877,9 @@ snmp_shutdown(const char *type)

     netsnmp_clear_tdomain_list();

     clear_callback();

     netsnmp_ds_shutdown();

+

+     clear_user_list();

+     free_etimelist();

 }

 

Mathew Bielejeski

http://www.neon.com

 

 

 

 

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to