aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ndb
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-17 19:30:59 +0000
committerrsc <devnull@localhost>2006-02-17 19:30:59 +0000
commitb65f95f6d862d4177d6c50b7fc5715d04b215a8d (patch)
tree40da14b7468c08c14724971c9e17b2f2ba85be21 /src/cmd/ndb
parent19256e0dd9c3c383ada7cc28b67487400c9162e3 (diff)
downloadplan9port-b65f95f6d862d4177d6c50b7fc5715d04b215a8d.tar.gz
plan9port-b65f95f6d862d4177d6c50b7fc5715d04b215a8d.tar.bz2
plan9port-b65f95f6d862d4177d6c50b7fc5715d04b215a8d.zip
add locking
Diffstat (limited to 'src/cmd/ndb')
-rwxr-xr-xsrc/cmd/ndb/dnudpserver.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cmd/ndb/dnudpserver.c b/src/cmd/ndb/dnudpserver.c
index 9e4ac4af..7ac3ac2e 100755
--- a/src/cmd/ndb/dnudpserver.c
+++ b/src/cmd/ndb/dnudpserver.c
@@ -21,6 +21,7 @@ struct Inprogress
int id;
};
Inprogress inprog[Maxactive+2];
+QLock inproglk;
/*
* record client id and ignore retransmissions.
@@ -32,6 +33,7 @@ clientrxmit(DNSmsg *req, uchar *buf)
Inprogress *p, *empty;
Udphdr *uh;
+ qlock(&inproglk);
uh = (Udphdr *)buf;
empty = 0;
for(p = inprog; p < &inprog[Maxactive]; p++){
@@ -43,17 +45,22 @@ clientrxmit(DNSmsg *req, uchar *buf)
if(req->id == p->id)
if(req->qd->owner == p->owner)
if(req->qd->type == p->type)
- if(memcmp(uh, &p->uh, Udphdrsize) == 0)
+ if(memcmp(uh, &p->uh, Udphdrsize) == 0){
+ qunlock(&inproglk);
return 0;
+ }
}
- if(empty == 0)
+ if(empty == 0){
+ qunlock(&inproglk);
return 0; /* shouldn't happen - see slave() and definition of Maxactive */
+ }
empty->id = req->id;
empty->owner = req->qd->owner;
empty->type = req->qd->type;
memmove(&empty->uh, uh, Udphdrsize);
empty->inuse = 1;
+ qunlock(&inproglk);
return empty;
}