[icinga-checkins] icinga.org: icinga-core/support/1.9: Don' t send MySQL pings for every single query.

git at icinga.org git at icinga.org
Sat Jun 22 17:53:42 CEST 2013


Module: icinga-core
Branch: support/1.9
Commit: f53478621f6daae8199fb76983e436b175c09520
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=f53478621f6daae8199fb76983e436b175c09520

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Apr 29 21:39:02 2013 +0200

Don't send MySQL pings for every single query.

---

 module/idoutils/include/db.h |    4 ++--
 module/idoutils/src/db.c     |   14 +++++++-------
 module/idoutils/src/ido2db.c |    2 ++
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/module/idoutils/include/db.h b/module/idoutils/include/db.h
index 66e31d8..c02c80a 100644
--- a/module/idoutils/include/db.h
+++ b/module/idoutils/include/db.h
@@ -141,8 +141,8 @@ int ido2db_db_init(ido2db_idi *);
 int ido2db_db_deinit(ido2db_idi *);
 
 int ido2db_db_connect(ido2db_idi *);
-int ido2db_db_is_connected(ido2db_idi *);
-int ido2db_db_reconnect(ido2db_idi *);
+int ido2db_db_is_connected(ido2db_idi *, int);
+int ido2db_db_reconnect(ido2db_idi *, int);
 int ido2db_db_disconnect(ido2db_idi *);
 
 int ido2db_db_hello(ido2db_idi *);
diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c
index cc6b65a..5e20922 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -374,10 +374,10 @@ int ido2db_db_deinit(ido2db_idi *idi) {
 /* connects to the database server  */
 /************************************/
 
-int ido2db_db_is_connected(ido2db_idi *idi) {
+int ido2db_db_is_connected(ido2db_idi *idi, int ping) {
 
 #ifdef USE_LIBDBI
-	if (!dbi_conn_ping(idi->dbinfo.dbi_conn))
+	if (ping && !dbi_conn_ping(idi->dbinfo.dbi_conn))
 		return IDO_FALSE;
 #endif
 
@@ -401,12 +401,12 @@ int ido2db_db_is_connected(ido2db_idi *idi) {
 	return IDO_TRUE;
 }
 
-int ido2db_db_reconnect(ido2db_idi *idi) {
+int ido2db_db_reconnect(ido2db_idi *idi, int ping) {
 
 	int result = IDO_OK;
 
 	/* check connection */
-	if (ido2db_db_is_connected(idi) == IDO_FALSE)
+	if (ido2db_db_is_connected(idi, ping) == IDO_FALSE)
 		idi->dbinfo.connected = IDO_FALSE;
 
 	/* try to reconnect... */
@@ -1168,7 +1168,7 @@ int ido2db_db_disconnect(ido2db_idi *idi) {
 
 
 	/* we're not connected... */
-	if (ido2db_db_is_connected(idi) == IDO_FALSE) {
+	if (ido2db_db_is_connected(idi, IDO_FALSE) == IDO_FALSE) {
 		ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_disconnect() already disconnected\n");
 #ifdef USE_ORACLE
 		OCI_Cleanup();
@@ -2514,7 +2514,7 @@ int ido2db_db_query(ido2db_idi *idi, char *buf) {
 		return IDO_ERROR;
 
 	/* if we're not connected, try and reconnect... */
-	if (ido2db_db_reconnect(idi) == IDO_ERROR)
+	if (ido2db_db_reconnect(idi, IDO_FALSE) == IDO_ERROR)
 		return IDO_ERROR;
 
 
@@ -2613,7 +2613,7 @@ int ido2db_handle_db_error(ido2db_idi *idi) {
 		return IDO_ERROR;
 
 	/* we're not currently connected... */
-	if (ido2db_db_is_connected(idi) == IDO_TRUE)
+	if (ido2db_db_is_connected(idi, IDO_FALSE) == IDO_TRUE)
 		return IDO_OK;
 
 	ido2db_db_disconnect(idi);
diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index 1832956..91a1a0b 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -1611,6 +1611,8 @@ int ido2db_handle_client_connection(int sd, ido2db_proxy *proxy) {
 
 		io_since_last_commit += result;
 
+		ido2db_db_reconnect(&idi, IDO_TRUE);
+
 		result = IDO_OK;
 
 		if (!in_transaction)





More information about the icinga-checkins mailing list