Patchwork [10/11] db: disable SIGHUP if ring buffer is used.

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

Comments

Eric Leblond - May 10, 2013, 6:48 a.m.
The handling of signal when using threads can be complicated. When
ring buffer is used for query, this means ulogd will have to follow
some sort of mutex. Thus, it is easier and better performance wise
to disable the reload via SIGHUP when the ring buffer is used.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 util/db.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch

diff --git a/util/db.c b/util/db.c
index 4050f0f..c23c362 100644
--- a/util/db.c
+++ b/util/db.c
@@ -607,11 +607,16 @@  static void *__inject_thread(void *gdi)
 
 void ulogd_db_signal(struct ulogd_pluginstance *upi, int signal)
 {
+	struct db_instance *di = (struct db_instance *) &upi->private;
 	switch (signal) {
 	case SIGHUP:
-		/* reopen database connection */
-		ulogd_db_instance_stop(upi);
-		ulogd_db_start(upi);
+		if (!di->ring.size) {
+			/* reopen database connection */
+			ulogd_db_instance_stop(upi);
+			ulogd_db_start(upi);
+		} else
+			ulogd_log(ULOGD_ERROR,
+				  "No SIGHUP handling if ring buffer is used\n");
 		break;
 	default:
 		break;