From 3b116b3189d9684d31d4b7d6c0ff27284b60cf12 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 22 Nov 2011 20:15:59 +0900 Subject: [PATCH] fix to use max-connections arg, and changing bind and listen to return booleans --- lib/chibi/accept.c | 2 +- lib/chibi/net.scm | 4 ++-- lib/chibi/net.stub | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/chibi/accept.c b/lib/chibi/accept.c index e4502ea0..480e015f 100644 --- a/lib/chibi/accept.c +++ b/lib/chibi/accept.c @@ -43,5 +43,5 @@ sexp sexp_listen (sexp ctx, sexp self, sexp arg0, sexp arg1) { if (res >= 0) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); #endif - return sexp_make_integer(ctx, res); + return (res == 0) ? SEXP_TRUE : SEXP_FALSE; } diff --git a/lib/chibi/net.scm b/lib/chibi/net.scm index af4d0b13..c3df676b 100644 --- a/lib/chibi/net.scm +++ b/lib/chibi/net.scm @@ -78,12 +78,12 @@ (error "couldn't create socket for: " addrinfo)) ((not (set-socket-option! sock level/socket socket-opt/reuseaddr 1)) (error "couldn't set the socket to be reusable" addrinfo)) - ((negative? (bind sock + ((not (bind sock (address-info-address addrinfo) (address-info-address-length addrinfo))) (close-file-descriptor sock) (error "couldn't bind socket for: " addrinfo)) - ((negative? (listen sock 100)) + ((not (listen sock max-connections)) (close-file-descriptor sock) (error "couldn't listen on socket for: " addrinfo)) (else diff --git a/lib/chibi/net.stub b/lib/chibi/net.stub index ecdc96ac..a5572902 100644 --- a/lib/chibi/net.stub +++ b/lib/chibi/net.stub @@ -28,7 +28,7 @@ ;;> Bind a name to a socket. -(define-c int bind (int sockaddr int)) +(define-c errno bind (int sockaddr int)) ;;> Listen on a socket.