shithub: mc

Download patch

ref: 59d49a9789ad8fae0d464e3e60e1196d7d861d18
parent: 210d305e98e146b37e0530a2463c9ed2de3fa648
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 11 17:46:00 EDT 2017

Announce now implicitly listens.

--- a/Makefile
+++ b/Makefile
@@ -37,4 +37,4 @@
 	./mbldwrap.sh uninstall
 
 release:
-	./support/release.sh 0.1.1
+	./support/release.sh 0.2.0
--- a/lib/http/server.myr
+++ b/lib/http/server.myr
@@ -14,17 +14,9 @@
 ;;
 
 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,
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -17,7 +17,6 @@
 
 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 @@
 	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)
 }
 
@@ -108,13 +110,6 @@
 	;;
 	-> `Ok (sock : fd)
 
-}
-
-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