linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: gustavo@padovan.org
Subject: [PATCH 1/4] Fix regression with debug via SIGUSR2
Date: Fri,  4 Jun 2010 23:23:39 -0300	[thread overview]
Message-ID: <1275704622-5917-1-git-send-email-gustavo@padovan.org> (raw)

The new dynamic debug feature was not using the SIGUSR2 signal so this was
causing bluetoothd to crash when one tries to toggle debug via SIGUSR2.
This patch brings back such compatibility.
---
 src/log.c  |   31 +++++++++++++++++++++++++++++--
 src/log.h  |    1 +
 src/main.c |    8 ++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/log.c b/src/log.c
index 29e2d7d..1c0f0b9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -95,9 +95,8 @@ static gboolean is_enabled(struct btd_debug_desc *desc)
         return 0;
 }
 
-void __btd_log_init(const char *debug, int detach)
+static void debug_on(const char *debug)
 {
-	int option = LOG_NDELAY | LOG_PID;
 	struct btd_debug_desc *desc;
 	const char *name = NULL, *file = NULL;
 
@@ -116,6 +115,34 @@ void __btd_log_init(const char *debug, int detach)
 		if (is_enabled(desc))
 			desc->flags |= BTD_DEBUG_FLAG_PRINT;
 	}
+}
+
+static void debug_off()
+{
+	struct btd_debug_desc *desc;
+
+	for (desc = __start___debug; desc < __stop___debug; desc++) {
+		if (is_enabled(desc))
+			desc->flags &= ~BTD_DEBUG_FLAG_PRINT;
+	}
+
+	g_strfreev(enabled);
+	enabled = NULL;
+}
+
+void __btd_toggle_debug()
+{
+	if (enabled == NULL)
+		debug_on("*");
+	else
+		debug_off();
+}
+
+void __btd_log_init(const char *debug, int detach)
+{
+	int option = LOG_NDELAY | LOG_PID;
+
+	debug_on(debug);
 
 	if (!detach)
 		option |= LOG_PERROR;
diff --git a/src/log.h b/src/log.h
index 9af51e7..a1530da 100644
--- a/src/log.h
+++ b/src/log.h
@@ -30,6 +30,7 @@ void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
 void __btd_log_init(const char *debug, int detach);
 void __btd_log_cleanup(void);
+void __btd_toggle_debug();
 
 struct btd_debug_desc {
         const char *name;
diff --git a/src/main.c b/src/main.c
index 3118a34..ba18523 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,6 +288,11 @@ static void sig_term(int sig)
 	g_main_loop_quit(event_loop);
 }
 
+static void sig_debug(int sig)
+{
+	__btd_toggle_debug();
+}
+
 static gchar *option_debug = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_udev = FALSE;
@@ -406,6 +411,9 @@ int main(int argc, char *argv[])
 	sigaction(SIGTERM, &sa, NULL);
 	sigaction(SIGINT,  &sa, NULL);
 
+	sa.sa_handler = sig_debug;
+	sigaction(SIGUSR2, &sa, NULL);
+
 	sa.sa_handler = SIG_IGN;
 	sigaction(SIGPIPE, &sa, NULL);
 
-- 
1.7.1


             reply	other threads:[~2010-06-05  2:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-05  2:23 Gustavo F. Padovan [this message]
2010-06-05  2:23 ` [PATCH 2/4] Add debug_string and debug_enabled vars Gustavo F. Padovan
2010-06-05  2:23   ` [PATCH 3/4] log: Remove vinfo function Gustavo F. Padovan
2010-06-05  2:23     ` [PATCH 4/4] Remove ifndef barrier from log.h and btio.h Gustavo F. Padovan
  -- strict thread matches above, loose matches on Subject: below --
2010-06-04 10:16 [PATCH 1/4] Fix regression with debug via SIGUSR2 Gustavo F. Padovan
2010-06-04 11:34 ` Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275704622-5917-1-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).