diff options
author | Amavect <amavect@gmail.com> | 2023-09-07 02:38:36 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-09-07 02:38:36 +0000 |
commit | e29fc9d0f23c62085114cb479032e07b0fb29abb (patch) | |
tree | 2244c0208dd48d98f30eb68f85ac7e148e212167 /btsd.c | |
parent | 2723bb6ff3e339f7f56a6276fa1c7c9f28d63871 (diff) | |
download | battleship-e29fc9d0f23c62085114cb479032e07b0fb29abb.tar.gz battleship-e29fc9d0f23c62085114cb479032e07b0fb29abb.tar.bz2 battleship-e29fc9d0f23c62085114cb479032e07b0fb29abb.zip |
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.
Diffstat (limited to 'btsd.c')
-rw-r--r-- | btsd.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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); } |