32 if((t = _strfindattr(a, "tag")) == nil){
33 flog("bad confirm write: no tag");
37 tag = strtoul(t, 0, 0);
38 if((ans = _strfindattr(a, "answer")) == nil){
39 flog("bad confirm write: no answer");
43 if(strcmp(ans, "yes") == 0)
45 else if(strcmp(ans, "no") == 0)
48 flog("bad confirm write: bad answer");
49 werrstr("bad answer");
52 for(c=conv; c; c=c->next){
54 nbsendul(c->keywait, allow);
59 werrstr("tag not found");
66 confirmkey(Conv *c, Key *k)
70 if(*confirminuse == 0)
73 lbappend(&confbuf, "confirm tag=%lud %A %N", c->tag, k->attr, k->privattr);
74 flog("confirm %A %N", k->attr, k->privattr);
75 c->state = "keyconfirm";
76 ret = recvul(c->keywait);
77 flog("confirm=%d %A %N", ret, k->attr, k->privattr);
86 lbread(&needkeybuf, r);
92 lbflush(&needkeybuf, r);
105 werrstr("empty write");
108 if((t = _strfindattr(a, "tag")) == nil){
113 tag = strtoul(t, 0, 0);
114 for(c=conv; c; c=c->next)
116 nbsendul(c->keywait, 0);
120 werrstr("tag not found");
129 needkey(Conv *c, Attr *a)
133 if(c == nil || *needkeyinuse == 0)
136 lbappend(&needkeybuf, "needkey tag=%lud %A", c->tag, a);
137 flog("needkey %A", a);
139 // Note: This code used to "return nbrecvul(c->keywait)."
140 // In Jan 2020 we changed nbrecvul to match Plan 9 and
141 // the man page and return 0 on "no data available" instead
142 // of -1. This new code with an explicit nbrecv preserves the
143 // code's old semantics, distinguishing a sent 0 from "no data".
144 // That said, this code seems to return -1 unconditionally:
145 // the c->keywait channel is unbuffered, and the only sending
146 // to it is done with an nbsendul, which won't block waiting for
147 // a receiver. So there is no sender for nbrecv to find here.
148 if(nbrecv(c->keywait, &u) < 0)
154 badkey(Conv *c, Key *k, char *msg, Attr *a)
158 if(c == nil || *needkeyinuse == 0)
161 lbappend(&needkeybuf, "badkey tag=%lud %A %N\n%s\n%A",
162 c->tag, k->attr, k->privattr, msg, a);
163 flog("badkey %A / %N / %s / %A",
164 k->attr, k->privattr, msg, a);
166 // Note: This code used to "return nbrecvul(c->keywait)."
167 // In Jan 2020 we changed nbrecvul to match Plan 9 and
168 // the man page and return 0 on "no data available" instead
169 // of -1. This new code with an explicit nbrecv preserves the
170 // code's old semantics, distinguishing a sent 0 from "no data".
171 // That said, this code seems to return -1 unconditionally:
172 // the c->keywait channel is unbuffered, and the only sending
173 // to it is done with an nbsendul, which won't block waiting for
174 // a receiver. So there is no sender for nbrecv to find here.
175 if(nbrecv(c->keywait, &u) < 0)