aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2020-01-15 10:48:20 -0500
committerRuss Cox <rsc@swtch.com>2020-01-15 10:49:28 -0500
commite75dbb6af8fbea53c62efb7176ed2d25a47557c9 (patch)
tree65d555449ece0485a9d1e4378f173c0a8b06aecf /src/cmd
parent2c3c82126b2e59d7951596adb863514eff45cf29 (diff)
downloadplan9port-e75dbb6af8fbea53c62efb7176ed2d25a47557c9.tar.gz
plan9port-e75dbb6af8fbea53c62efb7176ed2d25a47557c9.tar.bz2
plan9port-e75dbb6af8fbea53c62efb7176ed2d25a47557c9.zip
factotum: update for new nbrecvul return value
Unclear whether the old semantics were the right ones, but at least this preserves what they've been for the past however many years.
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/auth/factotum/confirm.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/cmd/auth/factotum/confirm.c b/src/cmd/auth/factotum/confirm.c
index 105a46db..8451e8ae 100644
--- a/src/cmd/auth/factotum/confirm.c
+++ b/src/cmd/auth/factotum/confirm.c
@@ -128,17 +128,33 @@ needkeywrite(char *s)
int
needkey(Conv *c, Attr *a)
{
+ ulong u;
+
if(c == nil || *needkeyinuse == 0)
return -1;
lbappend(&needkeybuf, "needkey tag=%lud %A", c->tag, a);
flog("needkey %A", a);
- return nbrecvul(c->keywait);
+
+ // Note: This code used to "return nbrecvul(c->keywait)."
+ // In Jan 2020 we changed nbrecvul to match Plan 9 and
+ // the man page and return 0 on "no data available" instead
+ // of -1. This new code with an explicit nbrecv preserves the
+ // code's old semantics, distinguishing a sent 0 from "no data".
+ // That said, this code seems to return -1 unconditionally:
+ // the c->keywait channel is unbuffered, and the only sending
+ // to it is done with an nbsendul, which won't block waiting for
+ // a receiver. So there is no sender for nbrecv to find here.
+ if(nbrecv(c->keywait, &u) < 0)
+ return -1;
+ return u;
}
int
badkey(Conv *c, Key *k, char *msg, Attr *a)
{
+ ulong u;
+
if(c == nil || *needkeyinuse == 0)
return -1;
@@ -146,5 +162,17 @@ badkey(Conv *c, Key *k, char *msg, Attr *a)
c->tag, k->attr, k->privattr, msg, a);
flog("badkey %A / %N / %s / %A",
k->attr, k->privattr, msg, a);
- return nbrecvul(c->keywait);
+
+ // Note: This code used to "return nbrecvul(c->keywait)."
+ // In Jan 2020 we changed nbrecvul to match Plan 9 and
+ // the man page and return 0 on "no data available" instead
+ // of -1. This new code with an explicit nbrecv preserves the
+ // code's old semantics, distinguishing a sent 0 from "no data".
+ // That said, this code seems to return -1 unconditionally:
+ // the c->keywait channel is unbuffered, and the only sending
+ // to it is done with an nbsendul, which won't block waiting for
+ // a receiver. So there is no sender for nbrecv to find here.
+ if(nbrecv(c->keywait, &u) < 0)
+ return -1;
+ return u;
}