diff options
author | Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> | 2022-06-10 20:22:39 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2022-06-10 20:22:39 +0000 |
commit | d618223086e32bc26d64eb20bfcb3de31536782f (patch) | |
tree | 9faf5d3e53bcc768b9bd00eeb46ae6ecc49ee5b7 | |
parent | 9fc38d43d45185c25cf74361b4bb778c611b015d (diff) |
ape/bsd/listen.c: Do not try to issue "announce *".
"port >= 0" is always true, because the port always gets filtered
through "htons" which returns "unsigned short", so we can just drop
the "else" branch here.
Anyway "announce 0" works fine with the Plan9 API, there is not need
for "announce *" here.
-rw-r--r-- | sys/src/ape/lib/bsd/listen.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sys/src/ape/lib/bsd/listen.c b/sys/src/ape/lib/bsd/listen.c index 045ff3a91..2ab995101 100644 --- a/sys/src/ape/lib/bsd/listen.c +++ b/sys/src/ape/lib/bsd/listen.c @@ -121,7 +121,7 @@ listen(fd, backlog) int backlog; { Rock *r; - int n, cfd, port; + int n, cfd; char msg[128]; struct sockaddr_un *lunix; @@ -139,17 +139,13 @@ listen(fd, backlog) errno = EBADF; return -1; } - port = _sock_inport(&r->addr); - if(port >= 0) { - if(write(cfd, "bind 0", 6) < 0) { - errno = EGREG; - close(cfd); - return -1; - } - snprintf(msg, sizeof msg, "announce %d", port); + /* FIXME: What is this good for? */ + if(write(cfd, "bind 0", 6) < 0) { + errno = EGREG; + close(cfd); + return -1; } - else - strcpy(msg, "announce *"); + snprintf(msg, sizeof msg, "announce %d", _sock_inport(&r->addr)); n = write(cfd, msg, strlen(msg)); if(n < 0){ errno = EOPNOTSUPP; /* Improve error reporting!!! */ |