Commit 9664125c86fae77cd2b88dbe0b6091e8a4d1634c

Baptiste 2024-08-09T13:53:57

tests: wip

diff --git a/lib/kc3/0.1/http/event.kc3 b/lib/kc3/0.1/http/event.kc3
index eb3b1e9..60f40a7 100644
--- a/lib/kc3/0.1/http/event.kc3
+++ b/lib/kc3/0.1/http/event.kc3
@@ -11,8 +11,8 @@ defmodule HTTP.Event do
 
   def dispatch = cfn S32 "event_base_dispatch" (Ptr)
 
-  # init() returns a (struct event_base *)
-  def event_base_new = cfn Ptr "event_base_new" ()
+  # base_new() returns a (struct event_base *)
+  def base_new = cfn Ptr "event_base_new" ()
 
   def new = cfn Ptr "http_event_new" (Ptr, S32, List, Fn, Tag)
 
diff --git a/test/http/07_event_echo.kc3 b/test/http/07_event_echo.kc3
index 97d367e..866468a 100644
--- a/test/http/07_event_echo.kc3
+++ b/test/http/07_event_echo.kc3
@@ -1,5 +1,5 @@
 timeout = %Time{tv_sec: (Sw) 300}
-event_base = HTTP.Event.init()
+event_base = HTTP.Event.base_new()
 socket = Socket.listen("0.0.0.0", "57000")
 echo_client = fn (socket, events, client_ev, client) do
   if List.has?(events, :read) && List.has(events, :write) do
@@ -11,7 +11,7 @@ end
 acceptor = fn (server_socket, events, acceptor_ev, void) do
   if List.has?(events, :read) do
     client = Socket.Buf.accept(server_socket)
-    client_ev = HTTP.Event.new(client.sockfd, [:read, :write],
+    client_ev = HTTP.Event.new(event_base, client.sockfd, [:read, :write],
       echo_client, client)
     puts(client_ev)
     HTTP.Event.base_set(event_base, client_ev)
@@ -19,11 +19,11 @@ acceptor = fn (server_socket, events, acceptor_ev, void) do
   end
 end
 puts(socket.fd)
-acceptor_ev = HTTP.Event.new(socket.fd, [:read], acceptor,
+acceptor_ev = HTTP.Event.new(event_base, socket.fd, [:read], acceptor,
                              void)
 puts(HTTP.Event.base_set(event_base, acceptor_ev))
 puts(HTTP.Event.add(acceptor_ev, timeout))
-r = HTTP.Event.dispatch()
+r = HTTP.Event.dispatch(event_base)
 if r do
   e = errno()
   puts("HTTP.Event.dispatch: #{r}: #{strerror(e)}")