From ef667b1ad89bb159b1991de0ec07d17e4320df23 Mon Sep 17 00:00:00 2001
From: eaglegai <eaglegai@163.com>
Date: Fri, 26 May 2023 16:44:34 +0800
Subject: [PATCH] BUG/MINOR: thread: add a check for pthread_create

preload_libgcc_s() use pthread_create to create a thread and then call
pthread_join to use it, but it doesn't check if the option is successful.
So add a check to aviod potential crash.

Conflict:NA
Reference:https://github.com/haproxy/haproxy/commit/ef667b1ad89bb159b1991de0ec07d17e4320df23

---
 src/thread.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/thread.c b/src/thread.c
index d7128252ed0e..b41b6628a4cb 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1066,8 +1066,8 @@ static void *dummy_thread_function(void *data)
 static inline void preload_libgcc_s(void)
 {
 	pthread_t dummy_thread;
-	pthread_create(&dummy_thread, NULL, dummy_thread_function, NULL);
-	pthread_join(dummy_thread, NULL);
+	if (pthread_create(&dummy_thread, NULL, dummy_thread_function, NULL) == 0)
+		pthread_join(dummy_thread, NULL);
 }
 
 static void __thread_init(void)
