Commit e69af8c29c3c2c4c75e1d3602ec5d2ddb196bf21

Baptiste 2024-08-12T14:16:33

working http server

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 {