We are running an application where we manage retrys of snmp requests
rather than defining the retrys in the session. What we would do is
create the pdu, then send the pdu and if we get an error rebuild the pdu
and send it again:
bool done = false;
int iRetryAttepmts = 0;
while(done == false){
struct snmp_pdu *pdu;
pdu = snmp_pdu_create();
//parse the oids in the request then add them to the pdu
status = snmp_sess_synch_response(sessp, pdu, &response);
if (status == STAT_SUCCESS){
if (response->errstat == SNMP_ERR_NOERROR){
done = true;//get was successful
}else{
iRetryAttepmts++;
if(iRetryAttepmts>iGetSetRetryAttepmts){
done = true;
}
}
}
}//end of while(done==false) loop
This worked pretty well but then we decided maybe if we could send all
the retrys out with the same request id as the original request, then if
we timed out on the first request, sent a second request but then
finally got the response to the first request we would then count it
good. So we added the following code to try to send requests out with
the same request id:
if(iRetryAttepmts==0){
myReqid = pdu->reqid;
}else{
pdu->reqid = myReqid;
}
Should we even be attempting this?
So the resulting overall code looks like this.
int myReqid;
bool done = false;
int iRetryAttepmts = 0;
while(done == false){
struct snmp_pdu *pdu;
pdu = snmp_pdu_create();
//parse the oids in the request then add them to the pdu
//new code here
if(iRetryAttepmts==0){
myReqid = pdu->reqid;
}else{
pdu->reqid = myReqid;
}
status = snmp_sess_synch_response(sessp, pdu, &response);
if (status == STAT_SUCCESS){
if (response->errstat == SNMP_ERR_NOERROR){
done = true;//get was successful
}else{
iRetryAttepmts++;
if(iRetryAttepmts>iGetSetRetryAttepmts){
done = true;
}
}
}
}//end of while(done==false) loop
The problem is now we are starting to see program crashes on time outs
where the stack trace looks like this:
snmp_sess_synch_response()
snmp_sess_timeout()
snmp_free_pdu()
snmp_free_varbind()
snmp_free_var()
Apparently it is attempting to free the pdu we passed to
snmp_sess_synch_response, but somehow it fails. Even though there
appears to be a good pdu being passed to snmp_sess_synch_response.
By attempting to manipulate the pdu->reqid are we somehow corrupting the
pdu (or some pointer) somewhere and causing the crash?
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders