Skip to contentSkip to conversation

alsabat: add terminate status check for capture thread

PATCH Applied [email protected] 2 participants 2 messages Apr 17, 2016 – Apr 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alsabat: add terminate status check for capture thread

From: "Lu, Han" <[email protected]>

In loopback test, alsabat use pthread_join(pthread_t thread, **retval) to wait for the capture thread to terminate. If the capture thread was canceled, PTHREAD_CANCELED is placed in *retval, and the access to the **retval will fail. Add status check to prevent illegal access to the **retval.

bat/bat.c +6 -0
index e824065..1afdcb4 100644
@@ -192,6 +192,12 @@ static void test_loopback(struct bat *bat)
 		exit(EXIT_FAILURE);
 	}
 
+	/* check if capture thread is canceled or not */
+	if (thread_result_capture == PTHREAD_CANCELED) {
+		fprintf(bat->log, _("Capture canceled.\n"));
+		return;
+	}
+
 	/* check capture status */
 	if (*thread_result_capture != 0) {
 		fprintf(bat->err, _("Exit capture thread fail: %d\n"),
Signature · 1 line
2.5.0
Applied
#1 lore raw
Quoted 10 lines · On Sun, 17 Apr 2016 03:26:45 +0200, [email protected] wrote:

From: "Lu, Han" <[email protected]>

In loopback test, alsabat use pthread_join(pthread_t thread, **retval) to wait for the capture thread to terminate. If the capture thread was canceled, PTHREAD_CANCELED is placed in *retval, and the access to the **retval will fail. Add status check to prevent illegal access to the **retval.

Applied, thanks.

Takashi

Quoted 20 lines
bat/bat.c +6 -0
index e824065..1afdcb4 100644
@@ -192,6 +192,12 @@ static void test_loopback(struct bat *bat)
 		exit(EXIT_FAILURE);
 	}
 
+	/* check if capture thread is canceled or not */
+	if (thread_result_capture == PTHREAD_CANCELED) {
+		fprintf(bat->log, _("Capture canceled.\n"));
+		return;
+	}
+
 	/* check capture status */
 	if (*thread_result_capture != 0) {
 		fprintf(bat->err, _("Exit capture thread fail: %d\n"),
Signature · 1 line
2.5.0