Diff between 2c71c128bff509340a361da685c5e64ed747635d and da5211fd185093e75d7c0fd3b04c5c9068c12155

Changed Files

File Additions Deletions Status
monitor/control.c +11 -2 modified
monitor/main.c +2 -5 modified

Full Patch

diff --git a/monitor/control.c b/monitor/control.c
index 92dc93a..3447b7a 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -43,8 +43,11 @@
 #include "display.h"
 #include "packet.h"
 #include "btsnoop.h"
+#include "hcidump.h"
 #include "control.h"
 
+static bool hcidump_fallback = false;
+
 #define MAX_PACKET_SIZE		(1486 + 4)
 
 struct control_data {
@@ -616,6 +619,7 @@ static int open_socket(uint16_t channel)
 	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		if (errno == EINVAL) {
 			/* Fallback to hcidump support */
+			hcidump_fallback = true;
 			close(fd);
 			return -1;
 		}
@@ -801,8 +805,13 @@ int control_tracing(void)
 	if (server_fd >= 0)
 		return 0;
 
-	if (open_channel(HCI_CHANNEL_MONITOR) < 0)
-		return -1;
+	if (open_channel(HCI_CHANNEL_MONITOR) < 0) {
+		if (!hcidump_fallback)
+			return -1;
+		if (hcidump_tracing() < 0)
+			return -1;
+		return 0;
+	}
 
 	open_channel(HCI_CHANNEL_CONTROL);
 
diff --git a/monitor/main.c b/monitor/main.c
index ac4dc1f..27a5722 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -35,7 +35,6 @@
 #include "mainloop.h"
 #include "packet.h"
 #include "control.h"
-#include "hcidump.h"
 #include "btsnoop.h"
 
 static void signal_callback(int signum, void *user_data)
@@ -149,10 +148,8 @@ int main(int argc, char *argv[])
 		return EXIT_SUCCESS;
 	}
 
-	if (control_tracing() < 0) {
-		if (hcidump_tracing() < 0)
-			return EXIT_FAILURE;
-	}
+	if (control_tracing() < 0)
+		return EXIT_FAILURE;
 
 	return mainloop_run();
 }