Howdy!

I have a question about when and when not to free a netsnmp_pdu. I have created a few MIB files for a project I am working on. I have also written the C code to handle the OIDs in those MIBs. I have that code running in an SNMP sub agent. All appears to be working well. But there is an issue that has been nagging me for a while.

I originally learned to write SNMP code by copying the tutorial code from net-snmp.sourceforge.net. For example, from http://net-snmp.sourceforge.net/tutorial-5/toolkit/demoapp/index.html. A relevent portion of my code, which obviously originated from the net-snmp tutorial, follows:

netsnmp_pdu *pdu = NULL;
netsnmp_pdu *response = NULL;
...
pdu = snmp_pdu_create(SNMP_MSG_GET);
...
status = snmp_synch_response(ss, pdu, &response);
...
if(response)
   snmp_free_pdu(response);

My question regarding the above code is why do we free the reponse PDU but not the pdu PDU??? In fact, when I have attempted to free the pdu PDU bad things have happened.

My specific reason for asking is this: I have a MIB handler which runs on a cluster master node. For several tasks, it attempts to get information from all of the cluster compute nodes. Thus, I have the block of code above in a loop which executes for each cluster compute node. If I'm not freeing pdu from the previous loop and getting a new one via snmp_pdu_create in each loop, do I have a memory leak somewhere???

Thanks.

-Steve



-------------------------------------------------------
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://productguide.itmanagersjournal.com/
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to