From 95b9bc0e533545a14cf12877c72e0d96ab4370fd Mon Sep 17 00:00:00 2001 From: Srinu Jella Date: Fri, 22 Jan 2016 17:49:15 +0530 Subject: [PATCH] Start listener thread only after successful open call Use case: Stress tests ON\OFF with different concurrent scenarios Failure: Crash in btsnoop_net_listen thread Root cause: While starting and shutting down the module we are calling same function update_logging(). While at the start it is creating listen thread and throwing error and exiting without closing the listen thread. While shutdown of module it "should_log" matches with "is_logging" and it considers cleanup is not required and returns, leaving Behind the listen thread open. In the next BT ON, another listen thread is created and causes the crash. Fix: Started listener thread after prerequisite operations are successful. Change-Id: I92ef293d9b061d0ea65a0c41b506870152114bb0 --- hci/src/btsnoop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.c index 50df9106c..ddeb7a9d9 100644 --- a/hci/src/btsnoop.c +++ b/hci/src/btsnoop.c @@ -158,8 +158,6 @@ static void update_logging() { is_logging = should_log; if (should_log) { - btsnoop_net_open(); - const char *log_path = stack_config->get_btsnoop_log_path(); // Save the old log if configured to do so @@ -179,6 +177,7 @@ static void update_logging() { } write(logfile_fd, "btsnoop\0\0\0\0\1\0\0\x3\xea", 16); + btsnoop_net_open(); } else { if (logfile_fd != INVALID_FD) close(logfile_fd); -- 2.11.0