[PATCH ulogd2 v2 v2 18/34] db: open-code `_loop_reconnect_db`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that `_loop_reconnect_db` returns `void`, it can be reduced to
`while (open_db fails) sleep 1 second`, so remove the function altogther
and open code the simplified while-loop.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 util/db.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/util/db.c b/util/db.c
index 0514a87e0759..afa86a3f137b 100644
--- a/util/db.c
+++ b/util/db.c
@@ -56,7 +56,6 @@ static int _process_backlog(struct ulogd_pluginstance *upi);
 
 static int _add_to_ring(struct ulogd_pluginstance *upi, struct db_instance *di);
 static void *_process_ring(void *arg);
-static void _loop_reconnect_db(struct ulogd_pluginstance *upi);
 
 int
 ulogd_db_configure(struct ulogd_pluginstance *upi,
@@ -694,10 +693,11 @@ _process_ring(void *gdi)
 		while (*wr_place == RING_QUERY_READY) {
 			if (di->driver->execute(upi, wr_place + 1,
 						strlen(wr_place + 1)) < 0) {
-				_loop_reconnect_db(upi);
+				di->driver->close_db(upi);
+				while (di->driver->open_db(upi) < 0)
+					sleep(1);
 				/* try to re run query */
 				continue;
-
 			}
 			*wr_place = RING_NO_QUERY;
 			di->ring.rd_item++;
@@ -711,18 +711,3 @@ _process_ring(void *gdi)
 
 	return NULL;
 }
-
-static void
-_loop_reconnect_db(struct ulogd_pluginstance * upi)
-{
-	struct db_instance *di = (struct db_instance *) &upi->private;
-
-	di->driver->close_db(upi);
-	while (1) {
-		if (di->driver->open_db(upi) < 0) {
-			sleep(1);
-		} else {
-			return;
-		}
-	}
-}
-- 
2.35.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux