From ebbadfc6e6a5041bc4dd15d8c8db327b13997b41 Mon Sep 17 00:00:00 2001 From: rodri Date: Fri, 8 Sep 2023 09:32:26 +0000 Subject: got rid of unused locking popplayer. use an fd for the threadgrp. --- btsd.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/btsd.c b/btsd.c index 861add4..ccc55b8 100644 --- a/btsd.c +++ b/btsd.c @@ -27,29 +27,12 @@ pushplayer(Player *p) fprint(2, "pushed fd %d sfd %d state %d\n", p->fd, p->sfd, p->state); } +/* XXX non-locking */ Player * popplayer(void) { Player *p; - p = nil; - qlock(&playerq); - if(playerq.nplayers > 0){ - p = playerq.players[0]; - memmove(&playerq.players[0], &playerq.players[1], --playerq.nplayers * sizeof p); - } - qunlock(&playerq); - if(debug) - fprint(2, "poppin fd %d sfd %d state %d\n", p->fd, p->sfd, p->state); - return p; -} - -/* non-locking version */ -Player * -nlpopplayer(void) -{ - Player *p; - p = nil; if(playerq.nplayers > 0){ p = playerq.players[0]; @@ -135,7 +118,7 @@ battleproc(void *arg) a[1].c = cp[1].c; a[1].v = &s; a[1].op = CHANRCV; a[2].op = CHANEND; - threadsetgrp(truerand()); + threadsetgrp(cp[0].fd); threadcreate(netrecvthread, &cp[0], mainstacksize); threadcreate(netrecvthread, &cp[1], mainstacksize); @@ -286,8 +269,8 @@ matchmaker(void *) } m = emalloc(sizeof *m); - m->pl[0] = nlpopplayer(); - m->pl[1] = nlpopplayer(); + m->pl[0] = popplayer(); + m->pl[1] = popplayer(); qunlock(&playerq); m->pl[0]->state = Waiting0; m->pl[1]->state = Waiting0; -- cgit v1.2.3