diff --git a/build.zig b/build.zig index de31e1a..5f132bb 100644 --- a/build.zig +++ b/build.zig @@ -53,7 +53,7 @@ pub fn addFacilio(exe: *std.build.LibExeObjStep) !void { if (b.is_release) try flags.append("-Os"); try flags.append("-Wno-return-type-c-linkage"); try flags.append("-fno-sanitize=undefined"); - + try flags.append("-DFIO_OVERRIDE_MALLOC"); exe.addIncludePath("./src/deps/facilio/libdump/all"); // Add C diff --git a/examples/hello/hello.zig b/examples/hello/hello.zig index 4fa3bde..0d0629f 100644 --- a/examples/hello/hello.zig +++ b/examples/hello/hello.zig @@ -7,15 +7,21 @@ fn on_request(request: [*c]zap.C.http_s) callconv(.C) void { } pub fn main() !void { + std.debug.print("debug1\n", .{}); // configure - var listen_settings = zap.ListenSettings.init(); + var listen_settings: zap.ListenSettings = .{}; + std.debug.print("debug2\n", .{}); listen_settings.on_request = on_request; listen_settings.log = true; + std.debug.print("debug3\n", .{}); + // listen try zap.listen("3000", null, listen_settings); std.debug.print("Listening on port 3000\n", .{}); + std.debug.print("debug4\n", .{}); + // start working zap.start(.{ .threads = 4, diff --git a/src/deps/facilio.zig b/src/deps/facilio.zig index 7829e3e..d08c51b 100644 --- a/src/deps/facilio.zig +++ b/src/deps/facilio.zig @@ -1,6 +1,7 @@ // zig type definitions for facilio lib // or maybe let's just make it zap directly... +const std = @import("std"); pub const C = @cImport({ @cInclude("http.h"); @cInclude("fio.h"); @@ -34,8 +35,7 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti } pfolder = pf.ptr; } - - if (C.http_listen(port, interface, .{ + var x: C.http_settings_s = .{ .on_request = settings.on_request, .on_upgrade = settings.on_upgrade, .on_response = settings.on_response, @@ -55,7 +55,11 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti .ws_timeout = 0, .log = if (settings.log) 1 else 0, .is_client = 0, - }) == -1) { + }; + // TODO: BUG: without this print statement, -Drelease* loop forever + // in debug2 and debug3 + std.debug.print("X\n", .{}); + if (C.http_listen(port, interface, x) == -1) { return error.ListenError; } }