From: Florian Forster Date: Wed, 3 Mar 2010 13:01:30 +0000 (+0100) Subject: oracle plugin: Fix semantics of OCIAttrGet. X-Git-Tag: collectd-4.8.4~17^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d0c4c77126d75a18bd4fff582a45f7fa313f845;p=collectd.git oracle plugin: Fix semantics of OCIAttrGet. Apparently it returns success if it could fetch the parameter value and doesn't interpret the value itself. So returning NULL when querying for OCI_ATTR_SERVER_STATUS does not result in an error. Handle this as a lost connection. Thanks to Sven for pointing this out :) --- diff --git a/src/oracle.c b/src/oracle.c index 49cf6571..7a8ccc6b 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -612,16 +612,22 @@ static int o_read_database (o_database_t *db) /* {{{ */ o_report_error ("o_read_database", "OCIAttrGet", oci_error); return (-1); } - assert (server_handle != NULL); - connection_status = 0; - status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER, - (void *) &connection_status, /* size pointer = */ NULL, - OCI_ATTR_SERVER_STATUS, oci_error); - if (status != OCI_SUCCESS) + if (server_handle == NULL) { - o_report_error ("o_read_database", "OCIAttrGet", oci_error); - return (-1); + connection_status = OCI_SERVER_NOT_CONNECTED; + } + else /* if (server_handle != NULL) */ + { + connection_status = 0; + status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER, + (void *) &connection_status, /* size pointer = */ NULL, + OCI_ATTR_SERVER_STATUS, oci_error); + if (status != OCI_SUCCESS) + { + o_report_error ("o_read_database", "OCIAttrGet", oci_error); + return (-1); + } } if (connection_status != OCI_SERVER_NORMAL)