Hi Robert,
Thanks for your reply and yes, I did forget to dup the PDU. I changed
the code and it is now working properly. Thank you for your help.
However, with the piece of code below, I found that the snmpd RSS memory
keeps increasing by 4K every 30 to 40 traps I sent out. Can you pinpoint
the source of my leak from the code. I ran my code in 5.4 and now in the
process of bringing it to 5.4.1pre3 to see if it would fix the leak.
int trapFwdSendTrap_callback( netsnmp_pdu *pdu )
{
netsnmp_session session;
netsnmp_session *ss;
netsnmp_pdu *clonedPdu;
char *destIpPortStr =
"172.30.250.195:162";
snmp_sess_init( &session);
session.peername = destIpPortStr;
session.version = SNMP_VERSION_2c;
ss = snmp_open( &session );
if (NULL != ss)
{
clonedPdu = snmp_clone_pdu( pdu );
if ( !snmp_send( ss, clonedPdu ) )
{
snmp_free_pdu( clonedPdu );
}
snmp_close( ss );
}
return(0);
}
Thanks,
Don
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Robert Story
Sent: Tuesday, June 19, 2007 10:14 AM
To: Tu, Don
Cc: [email protected]
Subject: [SPAM] - Re: Resending traps in trap callback function caused
agent to crash - Found word(s) list error in the Text body
On Fri, 15 Jun 2007 19:10:21 -0600 Don wrote:
TD> I have a trap callback function that checks the trap name against a
TD> list of predefined names and resend the traps to other hosts if the
TD> trap name matches a name in the list. This seems to work properly
TD> and I receive the forwarded traps on the received hosts with the
TD> correct trap names and values. In my test, I generate a trap every 5
TD> seconds or so, after about 40 traps are forwarded, the agent seems
TD> to exit without a core dump.
TD>
TD> This is the gist of my code:
TD>
TD>
TD> snmp_sess_init( &session );
TD> session.peername = "172.30.250.211:162"; session.version =
TD> SNMP_VERSION_2c;
TD>
TD> ss = snmp_sess_open( &session );
TD> snmp_sess_send( ss, pdu ); // pdu is passed in the callback
TD> snmp_sess_close( ss );
Sending a pdu will release it (unless and error occurs), so if you are
trying to send a trap to multiple destinations, you should dup the pdu
before sending it. You may even need to dup for the first destination,
if the callere doesn't expect you to release the pdu. (Then there is the
obvious issue of you not checking the send return code, and releasing
the pdu in case of an error.)
------------------------------------------------------------------------
-
This SF.net email is sponsored by DB2 Express Download DB2 Express C -
the FREE version of DB2 express and take control of your XML. No limits.
Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
The information contained in this e-mail message is PRIVATE. It may contain
confidential information and may be legally privileged. It is intended for the
exclusive use of the addressee(s). If you are not the intended recipient, you
are hereby notified that any dissemination, distribution or reproduction of
this communication is strictly prohibited. If the intended recipient(s) cannot
be reached or if a transmission problem has occurred, please notify the sender
immediately by return e-mail and destroy all copies of this message.
Thank you.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders