From e29fc9d0f23c62085114cb479032e07b0fb29abb Mon Sep 17 00:00:00 2001 From: Amavect Date: Thu, 7 Sep 2023 02:38:36 +0000 Subject: inline spawned threads to threadmain. Pointers to automatic variables become invalid when threadmain exits. Solution is to reuse threadmain. Use nbsend to avoid deadlock to the draw channel. Input struct is no longer needed, inline it. --- btsd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'btsd.c') diff --git a/btsd.c b/btsd.c index 5a722d2..861add4 100644 --- a/btsd.c +++ b/btsd.c @@ -299,14 +299,12 @@ matchmaker(void *) } void -listenthread(void *arg) +listenthread(char *addr) { - char *addr, adir[40], ldir[40], aux[128], *s; + char adir[40], ldir[40], aux[128], *s; int acfd, lcfd, dfd, sfd; Player *p; - addr = arg; - acfd = announce(addr, adir); if(acfd < 0) sysfatal("announce: %r"); @@ -357,12 +355,12 @@ threadmain(int argc, char *argv[]) case 'a': addr = EARGF(usage()); break; + default: usage(); }ARGEND if(argc != 0) usage(); proccreate(matchmaker, nil, mainstacksize); proccreate(reaper, nil, mainstacksize); - threadcreate(listenthread, addr, mainstacksize); - yield(); + listenthread(addr); } -- cgit v1.2.3