summaryrefslogtreecommitdiff
blob: 75f0a0198704a611f596a0f25b685030ba90b58e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--- xdb_sql/xdb_sql.c	2006/03/15 22:16:37	1210
+++ xdb_sql/xdb_sql.c	2006/04/25 22:01:39	1211
@@ -269,10 +269,18 @@
     ret = mysql_query(xq->mysql, query);
 
     /* failed and we need to reconnect? */
-    if (ret == CR_SERVER_LOST || ret == CR_SERVER_GONE_ERROR) {
-	xdb_sql_mysql_connect(i, xq);
+    if (ret) {
+	unsigned int query_errno = mysql_errno(xq->mysql);
+	if (query_errno == CR_SERVER_LOST || query_errno == CR_SERVER_GONE_ERROR) {
+	    log_debug2(ZONE, LOGT_STORAGE, "connection lost, trying to reconnect to MySQL server");
+	    xdb_sql_mysql_connect(i, xq);
 
-	ret = mysql_query(xq->mysql, query);
+	    ret = mysql_query(xq->mysql, query);
+
+	    if (ret == 0) {
+		log_notice(i->id, "connection to MySQL server %s:%i had been lost, and has been reestablished", xq->mysql_host , xq->mysql_port);
+	    }
+	}
     }
 
     /* still an error? log and return */