summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-25 20:10:16 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-25 20:10:16 +0000
commit5a168b291edd7a299c77f5615f36531ae2fb0f0e (patch)
tree8de4db53245d74fff3b9d9de23eebaf9f0ee7f1f /src
parentb6c78fc22404ded307191b277f18fbf92a169779 (diff)
downloadzabbix-5a168b291edd7a299c77f5615f36531ae2fb0f0e.tar.gz
zabbix-5a168b291edd7a299c77f5615f36531ae2fb0f0e.tar.xz
zabbix-5a168b291edd7a299c77f5615f36531ae2fb0f0e.zip
- [ZBX-295] fixed processing of null values under Oracle
- [ZBX-340] Oracle related fixes - [ZBX-294,ZBX-296] Oracle related fixes [svn merge svn://svn.zabbix.com/branches/1.4 -r5519:5522] [svn merge svn://svn.zabbix.com/branches/1.4 -r5525:5526] [svn merge svn://svn.zabbix.com/branches/1.4 -r5527:5529] git-svn-id: svn://svn.zabbix.com/trunk@5533 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxdb/db.c45
-rw-r--r--src/zabbix_server/watchdog/watchdog.c7
2 files changed, 31 insertions, 21 deletions
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c
index 9efeefc4..a353c1ac 100644
--- a/src/libs/zbxdb/db.c
+++ b/src/libs/zbxdb/db.c
@@ -54,7 +54,8 @@ void zbx_db_close(void)
conn = NULL;
#endif
#ifdef HAVE_ORACLE
- sqlo_finish(oracle);
+ if (SQLO_SUCCESS != sqlo_finish(oracle))
+ zabbix_log(LOG_LEVEL_ERR, "Cannot finish ORACLE session");
#endif
#ifdef HAVE_SQLITE3
sqlite_transaction_started = 0;
@@ -156,27 +157,38 @@ int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *d
return ret;
#endif
#ifdef HAVE_ORACLE
- char *connect = NULL;
+ char connect[MAX_STRING_LEN];
- if (SQLO_SUCCESS != sqlo_init(SQLO_OFF, 1, 100))
- {
+ if (SQLO_SUCCESS != sqlo_init(SQLO_OFF, 1, 100)) {
zabbix_log(LOG_LEVEL_ERR, "Failed to init libsqlora8");
- exit(FAIL);
+
+ ret = ZBX_DB_FAIL;
}
- /* login */ /* TODO: how to use port??? */
- connect = zbx_dsprintf(connect, "%s/%s@%s", user, password, dbname);
+ if (ZBX_DB_OK == ret) {
+ zbx_strlcpy(connect, user, sizeof(connect));
- if (SQLO_SUCCESS != sqlo_connect(&oracle, connect))
- {
- printf("Cannot login with %s\n", connect);
- zabbix_log(LOG_LEVEL_ERR, "Cannot login with %s", connect);
- exit(FAIL);
- }
+ if (password && *password) {
+ zbx_strlcat(connect, "/", sizeof(connect));
+ zbx_strlcat(connect, password, sizeof(connect));
- zbx_free(connect);
+ if (dbname && *dbname) {
+ zbx_strlcat(connect, "@", sizeof(connect));
+ zbx_strlcat(connect, dbname, sizeof(connect));
+ }
+ }
- sqlo_autocommit_on(oracle);
+ /* login */ /* TODO: how to use port??? */
+ if (SQLO_SUCCESS != sqlo_connect(&oracle, connect)) {
+ zabbix_log(LOG_LEVEL_ERR, "Cannot login with %s",
+ connect);
+
+ ret = ZBX_DB_FAIL;
+ }
+ }
+
+ if (ZBX_DB_OK == ret)
+ sqlo_autocommit_on(oracle);
return ret;
#endif
@@ -614,9 +626,6 @@ DB_ROW zbx_db_fetch(DB_RESULT result)
#ifdef HAVE_ORACLE
int res;
- /* EOF */
- if(!result) return NULL;
-
res = sqlo_fetch(result, 1);
if(SQLO_SUCCESS == res)
diff --git a/src/zabbix_server/watchdog/watchdog.c b/src/zabbix_server/watchdog/watchdog.c
index c12333c9..519c0e40 100644
--- a/src/zabbix_server/watchdog/watchdog.c
+++ b/src/zabbix_server/watchdog/watchdog.c
@@ -186,12 +186,13 @@ void main_watchdog_loop()
init_config();
- for(;;)
- {
+ DBclose();
+
+ for (;;) {
ping_database();
+
sleep(60);
}
/* We will never reach this point */
- DBclose();
}