static void csnmp_host_close_session (host_definition_t *host)
{
- int status;
-
if (host->sess_handle == NULL)
return;
- status = snmp_sess_close (host->sess_handle);
-
- if (status != 0)
- {
- char *errstr = NULL;
-
- snmp_sess_error (host->sess_handle, NULL, NULL, &errstr);
-
- ERROR ("snmp plugin: host %s: snmp_sess_close failed: %s",
- host->name, (errstr == NULL) ? "Unknown problem" : errstr);
- sfree (errstr);
- }
-
+ snmp_sess_close (host->sess_handle);
host->sess_handle = NULL;
} /* void csnmp_host_close_session */
for (i = 0; i < oid_list_len; i++)
snmp_add_null_var (req, oid_list[i].oid, oid_list[i].oid_len);
+ res = NULL;
status = snmp_sess_synch_response (host->sess_handle, req, &res);
if (status != STAT_SUCCESS)
ERROR ("snmp plugin: host %s: snmp_sess_synch_response failed: %s",
host->name, (errstr == NULL) ? "Unknown problem" : errstr);
csnmp_host_close_session (host);
+ sfree (errstr);
+
+ if (res != NULL)
+ snmp_free_pdu (res);
+ res = NULL;
status = -1;
break;
for (i = 0; i < data->values_len; i++)
snmp_add_null_var (req, data->values[i].oid, data->values[i].oid_len);
+
+ res = NULL;
status = snmp_sess_synch_response (host->sess_handle, req, &res);
if (status != STAT_SUCCESS)
csnmp_host_close_session (host);
sfree (errstr);
+ if (res != NULL)
+ snmp_free_pdu (res);
+ res = NULL;
+
return (-1);
}