Commit 20021578 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

selftests: net: tcp_mmap should create detached threads

Since we do not plan using pthread_join() in the server do_accept()
loop, we better create detached threads, or risk increasing memory
footprint over time.

Fixes: 192dc405 ("selftests: net: add tcp_mmap program")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 61ca533c
...@@ -270,6 +270,11 @@ static void setup_sockaddr(int domain, const char *str_addr, ...@@ -270,6 +270,11 @@ static void setup_sockaddr(int domain, const char *str_addr,
static void do_accept(int fdlisten) static void do_accept(int fdlisten)
{ {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (setsockopt(fdlisten, SOL_SOCKET, SO_RCVLOWAT, if (setsockopt(fdlisten, SOL_SOCKET, SO_RCVLOWAT,
&chunk_size, sizeof(chunk_size)) == -1) { &chunk_size, sizeof(chunk_size)) == -1) {
perror("setsockopt SO_RCVLOWAT"); perror("setsockopt SO_RCVLOWAT");
...@@ -288,7 +293,7 @@ static void do_accept(int fdlisten) ...@@ -288,7 +293,7 @@ static void do_accept(int fdlisten)
perror("accept"); perror("accept");
continue; continue;
} }
res = pthread_create(&th, NULL, child_thread, res = pthread_create(&th, &attr, child_thread,
(void *)(unsigned long)fd); (void *)(unsigned long)fd);
if (res) { if (res) {
errno = res; errno = res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment