add locking
This commit is contained in:
parent
19256e0dd9
commit
b65f95f6d8
1 changed files with 9 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ struct Inprogress
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
Inprogress inprog[Maxactive+2];
|
Inprogress inprog[Maxactive+2];
|
||||||
|
QLock inproglk;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* record client id and ignore retransmissions.
|
* record client id and ignore retransmissions.
|
||||||
|
|
@ -32,6 +33,7 @@ clientrxmit(DNSmsg *req, uchar *buf)
|
||||||
Inprogress *p, *empty;
|
Inprogress *p, *empty;
|
||||||
Udphdr *uh;
|
Udphdr *uh;
|
||||||
|
|
||||||
|
qlock(&inproglk);
|
||||||
uh = (Udphdr *)buf;
|
uh = (Udphdr *)buf;
|
||||||
empty = 0;
|
empty = 0;
|
||||||
for(p = inprog; p < &inprog[Maxactive]; p++){
|
for(p = inprog; p < &inprog[Maxactive]; p++){
|
||||||
|
|
@ -43,17 +45,22 @@ clientrxmit(DNSmsg *req, uchar *buf)
|
||||||
if(req->id == p->id)
|
if(req->id == p->id)
|
||||||
if(req->qd->owner == p->owner)
|
if(req->qd->owner == p->owner)
|
||||||
if(req->qd->type == p->type)
|
if(req->qd->type == p->type)
|
||||||
if(memcmp(uh, &p->uh, Udphdrsize) == 0)
|
if(memcmp(uh, &p->uh, Udphdrsize) == 0){
|
||||||
|
qunlock(&inproglk);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(empty == 0)
|
if(empty == 0){
|
||||||
|
qunlock(&inproglk);
|
||||||
return 0; /* shouldn't happen - see slave() and definition of Maxactive */
|
return 0; /* shouldn't happen - see slave() and definition of Maxactive */
|
||||||
|
}
|
||||||
|
|
||||||
empty->id = req->id;
|
empty->id = req->id;
|
||||||
empty->owner = req->qd->owner;
|
empty->owner = req->qd->owner;
|
||||||
empty->type = req->qd->type;
|
empty->type = req->qd->type;
|
||||||
memmove(&empty->uh, uh, Udphdrsize);
|
memmove(&empty->uh, uh, Udphdrsize);
|
||||||
empty->inuse = 1;
|
empty->inuse = 1;
|
||||||
|
qunlock(&inproglk);
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue