Skip to content

Commit

Permalink
CHANGES: PATCH 1633670: fixed snmpd crashing when an AgentX subagent …
Browse files Browse the repository at this point in the history
…disconnect in the middle of processing of a request.

I fixed also the memory leak reported in the tracker comments.
  • Loading branch information
Jan Safranek committed Feb 7, 2012
1 parent 41d1b48 commit f9304c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions agent/mibgroup/agentx/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ agentx_got_response(int operation,
if (!cache) {
DEBUGMSGTL(("agentx/master", "response too late on session %8p\n",
session));
/* response is too late, free the cache */
if (magic)
netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
return 0;
}
requests = cache->requests;
Expand Down Expand Up @@ -606,6 +609,8 @@ agentx_master_handler(netsnmp_mib_handler *handler,
result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
if (result == 0) {
snmp_free_pdu(pdu);
if (cb_data)
netsnmp_free_delegated_cache((netsnmp_delegated_cache*) cb_data);
}

return SNMP_ERR_NOERROR;
Expand Down
9 changes: 7 additions & 2 deletions agent/mibgroup/agentx/master_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ close_agentx_session(netsnmp_session * session, int sessid)
* requests, so that the delegated request will be completed and
* further requests can be processed
*/
netsnmp_remove_delegated_requests_for_session(session);
while (netsnmp_remove_delegated_requests_for_session(session)) {
DEBUGMSGTL(("agentx/master", "Continue removing delegated reqests\n"));
}

if (session->subsession != NULL) {
netsnmp_session *subsession = session->subsession;
for(; subsession; subsession = subsession->next) {
netsnmp_remove_delegated_requests_for_session(subsession);
while (netsnmp_remove_delegated_requests_for_session(subsession)) {
DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession reqests\n"));
}
}
}

Expand Down

0 comments on commit f9304c8

Please sign in to comment.