>>>>> On Tue, 18 Oct 2005 13:06:23 -0400, Robert Story <[EMAIL PROTECTED]> said:
Robert> On Tue, 18 Oct 2005 15:28:17 +0100 Dave wrote: DS> I'd suggest that the more important thing here is avoiding an DS> agent crash. We can live with a minor memory leak in the short DS> term. (We've done so plenty of times before!) Robert> I agree... That's 4/4 so far, so go for it.. FYI, final patch to be checked in: (and I did verify that other code using async doesn't free the response pdu either. How inconsistent we are.) Index: agent_trap.c =================================================================== RCS file: /cvsroot/net-snmp/net-snmp/agent/agent_trap.c,v retrieving revision 5.24 diff -u -p -r5.24 agent_trap.c --- agent_trap.c 30 Aug 2005 00:08:44 -0000 5.24 +++ agent_trap.c 19 Oct 2005 05:00:17 -0000 @@ -800,6 +800,45 @@ send_enterprise_trap_vars(int trap, return; } +/** + * Captures responses or the lack there of from INFORMs that were sent + * 1) a response is received from an INFORM + * 2) one isn't received and the retries/timeouts have failed +*/ +int +handle_inform_response(int op, netsnmp_session * session, + int reqid, netsnmp_pdu *pdu, + void *magic) +{ + /* XXX: possibly stats update */ + switch (op) { + + case NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE: + snmp_increment_statistic(STAT_SNMPINPKTS); + DEBUGMSGTL(("trap", "received the inform response for reqid=%d\n", + reqid)); + break; + + case NETSNMP_CALLBACK_OP_TIMED_OUT: + DEBUGMSGTL(("trap", + "received a timeout sending an inform for reqid=%d\n", + reqid)); + break; + + case NETSNMP_CALLBACK_OP_SEND_FAILED: + DEBUGMSGTL(("trap", + "failed to send an inform for reqid=%d\n", + reqid)); + break; + + default: + DEBUGMSGTL(("trap", "received op=%d for reqid=%d when trying to send an inform\n", op, reqid)); + } + + return 1; +} + + /* * send_trap_to_sess: sends a trap to a session but assumes that the * pdu is constructed correctly for the session type. @@ -808,7 +847,6 @@ void send_trap_to_sess(netsnmp_session * sess, netsnmp_pdu *template_pdu) { netsnmp_pdu *pdu; - netsnmp_pdu *response; int result; if (!sess || !template_pdu) @@ -831,10 +869,13 @@ send_trap_to_sess(netsnmp_session * sess || template_pdu->command == AGENTX_MSG_NOTIFY #endif ) { - result = snmp_synch_response(sess, pdu, &response); - result = !result; /* XXX - different return code :-( */ - } else + result = + snmp_async_send(sess, pdu, &handle_inform_response, NULL); + + } else { result = snmp_send(sess, pdu); + } + if (result == 0) { snmp_sess_perror("snmpd: send_trap", sess); /* snmp_free_pdu(pdu); */ -- Wes Hardaker Sparta, Inc. ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders