From d7e2022bdd1626fbcb614710bec20b4a42278f9a Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 18 Sep 2020 15:29:47 +0200 Subject: #941 pass og_dbi to og_dbi_get_computer_info() Reuse the existing dbi handler, instead of opening a new one. --- src/dbi.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/dbi.c') diff --git a/src/dbi.c b/src/dbi.c index 51edf31..94f3de8 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -49,18 +49,12 @@ void og_dbi_close(struct og_dbi *dbi) free(dbi); } -int og_dbi_get_computer_info(struct og_computer *computer, struct in_addr addr) +int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer, + struct in_addr addr) { const char *msglog; - struct og_dbi *dbi; dbi_result result; - dbi = og_dbi_open(&dbi_config); - if (!dbi) { - syslog(LOG_ERR, "cannot open connection database (%s:%d)\n", - __func__, __LINE__); - return -1; - } result = dbi_conn_queryf(dbi->conn, "SELECT ordenadores.idordenador," " ordenadores.nombreordenador," @@ -74,14 +68,12 @@ int og_dbi_get_computer_info(struct og_computer *computer, struct in_addr addr) dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", __func__, __LINE__, msglog); - og_dbi_close(dbi); return -1; } if (!dbi_result_next_row(result)) { syslog(LOG_ERR, "client does not exist in database (%s:%d)\n", __func__, __LINE__); dbi_result_free(result); - og_dbi_close(dbi); return -1; } @@ -94,7 +86,6 @@ int og_dbi_get_computer_info(struct og_computer *computer, struct in_addr addr) OG_DB_COMPUTER_NAME_MAXLEN); dbi_result_free(result); - og_dbi_close(dbi); return 0; } -- cgit v1.2.3-18-g5258