1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:34:42 -07:00

bug in select default

R=r
OCL=18741
CL=18741
This commit is contained in:
Ken Thompson 2008-11-06 17:50:28 -08:00
parent 9c7374d71b
commit 9b827cf9a0

View File

@ -408,6 +408,8 @@ sys·newselect(int32 size, Select *sel)
if(debug) { if(debug) {
prints("newselect s="); prints("newselect s=");
sys·printpointer(sel); sys·printpointer(sel);
prints("newselect size=");
sys·printint(size);
prints("\n"); prints("\n");
} }
} }
@ -523,8 +525,6 @@ sys·selectdefault(Select *sel, ...)
sys·printpointer(sel); sys·printpointer(sel);
prints(" pc="); prints(" pc=");
sys·printpointer(cas->pc); sys·printpointer(cas->pc);
prints(" chan=");
sys·printpointer(cas->chan);
prints(" so="); prints(" so=");
sys·printint(cas->so); sys·printint(cas->so);
prints(" send="); prints(" send=");
@ -544,7 +544,6 @@ sys·selectgo(Select *sel)
Hchan *c; Hchan *c;
SudoG *sg; SudoG *sg;
G *gp; G *gp;
byte *as; byte *as;
if(xxx) { if(xxx) {
@ -581,31 +580,35 @@ sys·selectgo(Select *sel)
dfl = nil; dfl = nil;
for(i=0; i<sel->ncase; i++) { for(i=0; i<sel->ncase; i++) {
cas = &sel->scase[o]; cas = &sel->scase[o];
if(cas->send == 2) { // default if(cas->send == 2) { // default
dfl = cas; dfl = cas;
continue; goto next1;
} }
c = cas->chan; c = cas->chan;
if(c->dataqsiz > 0) { if(c->dataqsiz > 0) {
if(cas->send) { if(cas->send) {
if(c->qcount < c->dataqsiz) if(c->qcount < c->dataqsiz)
goto asyns; goto asyns;
} else { goto next1;
if(c->qcount > 0)
goto asynr;
} }
} else if(c->qcount > 0)
goto asynr;
goto next1;
}
if(cas->send) { if(cas->send) {
sg = dequeue(&c->recvq, c); sg = dequeue(&c->recvq, c);
if(sg != nil) if(sg != nil)
goto gots; goto gots;
} else { goto next1;
sg = dequeue(&c->sendq, c);
if(sg != nil)
goto gotr;
} }
sg = dequeue(&c->sendq, c);
if(sg != nil)
goto gotr;
next1:
o += p; o += p;
if(o >= sel->ncase) if(o >= sel->ncase)
o -= sel->ncase; o -= sel->ncase;
@ -631,16 +634,17 @@ sys·selectgo(Select *sel)
sg = allocsg(c); sg = allocsg(c);
sg->offset = o; sg->offset = o;
enqueue(&c->sendq, sg); enqueue(&c->sendq, sg);
} else { goto next2;
if(c->qcount > 0) {
prints("selectgo: pass 2 async recv\n");
goto asynr;
}
sg = allocsg(c);
sg->offset = o;
enqueue(&c->recvq, sg);
} }
} else if(c->qcount > 0) {
prints("selectgo: pass 2 async recv\n");
goto asynr;
}
sg = allocsg(c);
sg->offset = o;
enqueue(&c->recvq, sg);
goto next2;
}
if(cas->send) { if(cas->send) {
sg = dequeue(&c->recvq, c); sg = dequeue(&c->recvq, c);
@ -653,18 +657,19 @@ sys·selectgo(Select *sel)
sg->offset = o; sg->offset = o;
c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem); c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem);
enqueue(&c->sendq, sg); enqueue(&c->sendq, sg);
} else { goto next2;
sg = dequeue(&c->sendq, c);
if(sg != nil) {
prints("selectgo: pass 2 sync recv\n");
g->selgen++;
goto gotr;
}
sg = allocsg(c);
sg->offset = o;
enqueue(&c->recvq, sg);
} }
sg = dequeue(&c->sendq, c);
if(sg != nil) {
prints("selectgo: pass 2 sync recv\n");
g->selgen++;
goto gotr;
}
sg = allocsg(c);
sg->offset = o;
enqueue(&c->recvq, sg);
next2:
o += p; o += p;
if(o >= sel->ncase) if(o >= sel->ncase)
o -= sel->ncase; o -= sel->ncase;