From 05126d9fac4c509ac8075260f14dc747db4b62b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E8=BE=9C=E7=9A=84=E7=86=8A=E6=9C=AC=E7=86=8A?= <10804640+innocent-kumamoto@user.noreply.gitee.com> Date: Fri, 12 Jul 2024 07:40:51 +0000 Subject: [PATCH 1/2] update src/simplehttpd.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 无辜的熊本熊 <10804640+innocent-kumamoto@user.noreply.gitee.com> --- src/simplehttpd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/simplehttpd.c b/src/simplehttpd.c index d4b943d..bab1d3c 100644 --- a/src/simplehttpd.c +++ b/src/simplehttpd.c @@ -392,6 +392,7 @@ int StartHttpServerSync(const char *ip, uint16_t port) struct sockaddr_in client_name; socklen_t client_name_len = sizeof(client_name); pthread_t newthread; + pthread_attr_t threadAttr; struct sockaddr_in name; server_sock = socket(PF_INET, SOCK_STREAM, 0); @@ -453,7 +454,9 @@ int StartHttpServerSync(const char *ip, uint16_t port) continue; } - if (pthread_create(&newthread, NULL, accept_request, (void *)&client_sock) != 0) + pthread_attr_init(&threadAttr); + pthread_attr_setdetachstate(&threadAttr,PTHREAD_CREATE_DETACHED); + if (pthread_create(&newthread, &threadAttr, accept_request, (void *)&client_sock) != 0) { HTTPD_LOG_ERROR("create new thread failed."); close(client_sock); -- Gitee From f772b7eeb5bce19fa648e352ef1695dc3408edab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E8=BE=9C=E7=9A=84=E7=86=8A=E6=9C=AC=E7=86=8A?= <10804640+innocent-kumamoto@user.noreply.gitee.com> Date: Fri, 12 Jul 2024 07:51:10 +0000 Subject: [PATCH 2/2] update src/simplehttpd.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 无辜的熊本熊 <10804640+innocent-kumamoto@user.noreply.gitee.com> --- src/simplehttpd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/simplehttpd.c b/src/simplehttpd.c index bab1d3c..f0a8271 100644 --- a/src/simplehttpd.c +++ b/src/simplehttpd.c @@ -455,12 +455,13 @@ int StartHttpServerSync(const char *ip, uint16_t port) } pthread_attr_init(&threadAttr); - pthread_attr_setdetachstate(&threadAttr,PTHREAD_CREATE_DETACHED); + pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); if (pthread_create(&newthread, &threadAttr, accept_request, (void *)&client_sock) != 0) { HTTPD_LOG_ERROR("create new thread failed."); close(client_sock); } + pthread_attr_destroy(&threadAttr); } close(server_sock); -- Gitee