summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 65127ea)
raw | patch | inline | side by side (parent: 65127ea)
author | Florian Forster <octo@noris.net> | |
Tue, 6 Nov 2007 15:53:49 +0000 (15:53 +0000) | ||
committer | Florian Forster <octo@noris.net> | |
Tue, 6 Nov 2007 15:53:49 +0000 (15:53 +0000) |
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index 4bcdcf7d486f7a35554b3a64249938f72c0d5ab0..f1b366b6a010b5fe75ac0dbcd823c30296258089 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
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;
@@ -1081,6 +1073,8 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
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)
@@ -1093,6 +1087,10 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
csnmp_host_close_session (host);
sfree (errstr);
+ if (res != NULL)
+ snmp_free_pdu (res);
+ res = NULL;
+
return (-1);
}