Could you please explain - reuse the response pdu to create a new pdu? My code is organized like this:

My function A() is a member function of a class, when it is called, it is passed in an OID of an table. Inside function A(), I declared two local variable:
struct snmp_pdu *pdu;
struct snmp_pdu *response;

both without allocating memory. I thought snmp_pdu_create() allocate memory for pdu.

Then A() flows like:

while(not finished with that table) {
 pdu = snmp_pdu_create();
 ...
 status = snmp_sess_synch_resposne(sessp, pdu, &response);
 if(status == SUCESSS && response != NULL) {
        process the response;
        snmp_free_pdu(response);
 }

}

I called A() every time I need to query a new table, and it core dumped on the second time the A() is called.

Thank you again.

From: Wes Hardaker <[EMAIL PROTECTED]>
To: "Haizhu Liu" <[EMAIL PROTECTED]>
CC: [email protected]
Subject: Re: snprint_value
Date: Wed, 30 Nov 2005 10:19:23 -0800

>>>>> On Tue, 29 Nov 2005 15:30:46 -0500, "Haizhu Liu" <[EMAIL PROTECTED]> said:

Haizhu> 1. I queried the agent a whole big table, when I got the
Haizhu> information, I am parsing it using snprint_value, it seems CPU
Haizhu> usage jumps up whenever snprint_value is called? Any
Haizhu> suggestion?

I'm not sure about that one without figuring out *why* it's taking so
much time.

Haizhu> 2. I saw a post before saying whenever the request comes back
Haizhu> successfully, the pdu is freed up by the library, and
Haizhu> application needs to free up the response. I am doing querying
Haizhu> for table after table, if I free up the response to the first
Haizhu> response, I seems to get core-dump afterwards. Any suggestion?

If you're re-using the response PDU to create a new PDU then that will
be problematic and you shouldn't free it.  If you've put in static
data into the initial PDU that wasn't allocated in the first place,
you'll run into similar problems since snmp_free_pdu will try to free it...

--
Wes Hardaker
Sparta, Inc.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to