Skip to content

Commit

Permalink
selftests: net: tcp_mmap should create detached threads
Browse files Browse the repository at this point in the history
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: 192dc40 ("selftests: net: add tcp_mmap program")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 15, 2019
1 parent 61ca533 commit 2002157
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/testing/selftests/net/tcp_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ static void setup_sockaddr(int domain, const char *str_addr,

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,
&chunk_size, sizeof(chunk_size)) == -1) {
perror("setsockopt SO_RCVLOWAT");
Expand All @@ -288,7 +293,7 @@ static void do_accept(int fdlisten)
perror("accept");
continue;
}
res = pthread_create(&th, NULL, child_thread,
res = pthread_create(&th, &attr, child_thread,
(void *)(unsigned long)fd);
if (res) {
errno = res;
Expand Down

0 comments on commit 2002157

Please sign in to comment.