summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-11 21:46:00 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-11 23:28:03 -0700
commit59d49a9789ad8fae0d464e3e60e1196d7d861d18 (patch)
tree145d9a4053240fd5e4e29a94e21dc5528d31a2a7
parent210d305e98e146b37e0530a2463c9ed2de3fa648 (diff)
downloadmc-59d49a9789ad8fae0d464e3e60e1196d7d861d18.tar.gz
Announce now implicitly listens.
-rw-r--r--Makefile2
-rw-r--r--lib/http/server.myr8
-rw-r--r--lib/std/listen+posixy.myr11
3 files changed, 4 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 9775526..00829ed 100644
--- a/Makefile
+++ b/Makefile
@@ -37,4 +37,4 @@ uninstallmyr:
./mbldwrap.sh uninstall
release:
- ./support/release.sh 0.1.1
+ ./support/release.sh 0.2.0
diff --git a/lib/http/server.myr b/lib/http/server.myr
index 8b221bd..90fba7e 100644
--- a/lib/http/server.myr
+++ b/lib/http/server.myr
@@ -14,17 +14,9 @@ pkg http =
;;
const announce = {ds
- var afd
-
match std.announce(ds)
- | `std.Ok f: afd = f
- | `std.Err e: -> `std.Err `Econn
- ;;
-
- match std.listen(afd)
| `std.Err e: -> `std.Err `Econn
| `std.Ok lfd:
- std.close(afd)
-> `std.Ok std.mk([
.refs=1,
.lfd=lfd,
diff --git a/lib/std/listen+posixy.myr b/lib/std/listen+posixy.myr
index be4456d..7f4b35b 100644
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -17,7 +17,6 @@ use "utf"
pkg std =
const announce : (ds : byte[:] -> result(fd, byte[:]))
- const listen : (sock : fd -> result(fd, byte[:]))
const accept : (lfd : fd -> result(fd, byte[:]))
;;
@@ -80,6 +79,9 @@ const announcesock = {proto, str
if sys.bind(sock, sa, sz) < 0
-> `Err "failed to bind socket"
;;
+ if sys.listen((sock : sys.fd), 10) < 0
+ -> `Err "unable to listen on socket"
+ ;;
-> `Ok (sock : fd)
}
@@ -110,13 +112,6 @@ const announceunix = {path
}
-const listen = {sock : std.fd -> result(fd, byte[:])
- if sys.listen((sock : sys.fd), 10) < 0
- -> `Err "unable to listen on socket"
- ;;
- -> `Ok (sys.dup((sock : sys.fd)) : fd)
-}
-
const accept = {lfd
var sa : sys.sockaddr_storage
var len : sys.size