working http server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/http/http_event.c b/http/http_event.c
index 1ad3647..eb938f2 100644
--- a/http/http_event.c
+++ b/http/http_event.c
@@ -18,6 +18,8 @@
s32 http_event_add (struct event **ev, s_time *time)
{
struct timeval tv;
+ if (! time->tv_sec && ! time->tv_nsec)
+ return event_add(*ev, NULL);
tv.tv_sec = time->tv_sec;
tv.tv_usec = time->tv_nsec / 1000;
return event_add(*ev, &tv);
diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index 4dd2c49..35bdd51 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -33,8 +33,9 @@ defmodule HTTPd do
end
end
+ def timeout = %Time{}
+
def server = fn (host, port) {
- timeout = %Time{tv_sec: (Sw) 30}
event_base = HTTP.Event.base_new()
socket = Socket.listen(host, port)
puts("KC3 HTTPd: listening on #{host}:#{port}")
@@ -44,8 +45,9 @@ defmodule HTTPd do
r = HTTP.Event.dispatch(event_base)
if r do
e = errno()
+ puts("KC3 HTTPd: event dispatch error: #{strerror(e)}")
end
- Socket.close(%Socket{fd: socket})
+ Socket.close(socket)
}
def main = fn {