Patchwork [11/11] db: db ring has precedence over backlog.

login
register
mail settings
Submitter Eric Leblond
Date May 10, 2013, 6:48 a.m.
Message ID <1368168538-29780-12-git-send-email-eric@regit.org>
Download mbox | patch
Permalink /patch/242920/
State Accepted
Headers show

Comments

Eric Leblond - May 10, 2013, 6:48 a.m.
Signed-off-by: Eric Leblond <eric@regit.org>
---
 util/db.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/util/db.c b/util/db.c
index c23c362..6be06e6 100644
--- a/util/db.c
+++ b/util/db.c
@@ -177,9 +177,14 @@  int ulogd_db_configure(struct ulogd_pluginstance *upi,
 
 	INIT_LLIST_HEAD(&di->backlog);
 	di->backlog_memusage = 0;
-	
+
+	di->ring.size = ringsize_ce(upi->config_kset).u.value;
 	di->backlog_memcap = backlog_memcap_ce(upi->config_kset).u.value;
-	if (di->backlog_memcap > 0) {
+
+	if (di->ring.size && di->backlog_memcap) {
+		ulogd_log(ULOGD_ERROR, "Ring buffer has precedence over backlog\n");
+		di->backlog_memcap = 0;
+	} else if (di->backlog_memcap > 0) {
 		di->backlog_oneshot = backlog_oneshot_ce(upi->config_kset).u.value;
 		if (di->backlog_oneshot <= 2) {
 			ulogd_log(ULOGD_ERROR,
@@ -190,9 +195,6 @@  int ulogd_db_configure(struct ulogd_pluginstance *upi,
 		di->backlog_full = 0;
 	}
 
-	/* check ring option */
-	di->ring.size = ringsize_ce(upi->config_kset).u.value;
-
 	return ret;
 }