From d91df53ee78cedfdf855fe0e58ff3d38754f5239 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Wed, 11 Jan 2023 23:09:04 +0100 Subject: [PATCH] introduced sleep workaround and exact logging --- build.zig | 1 + examples/hello/hello.zig | 9 +++++---- src/deps/facilio.zig | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 17958d9..5f73df6 100644 --- a/build.zig +++ b/build.zig @@ -61,6 +61,7 @@ pub fn addFacilio(exe: *std.build.LibExeObjStep) !void { try flags.append("-Wno-return-type-c-linkage"); try flags.append("-fno-sanitize=undefined"); try flags.append("-DFIO_OVERRIDE_MALLOC"); + try flags.append("-DFIO_HTTP_EXACT_LOGGING"); exe.addIncludePath("./src/deps/facilio/libdump/all"); // Add C diff --git a/examples/hello/hello.zig b/examples/hello/hello.zig index 0d0629f..f7ad379 100644 --- a/examples/hello/hello.zig +++ b/examples/hello/hello.zig @@ -3,24 +3,25 @@ const zap = @import("facilio"); fn on_request(request: [*c]zap.C.http_s) callconv(.C) void { std.debug.print("GOT A REQUEST!\n", .{}); + // std.time.sleep(5 * 1000 * 1000); _ = zap.sendBody(request, "Hello from ZAP!!!"); } pub fn main() !void { - std.debug.print("debug1\n", .{}); + // std.debug.print("debug1\n", .{}); // configure var listen_settings: zap.ListenSettings = .{}; - std.debug.print("debug2\n", .{}); + // std.debug.print("debug2\n", .{}); listen_settings.on_request = on_request; listen_settings.log = true; - std.debug.print("debug3\n", .{}); + // 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", .{}); + // std.debug.print("debug4\n", .{}); // start working zap.start(.{ diff --git a/src/deps/facilio.zig b/src/deps/facilio.zig index d08c51b..4464f98 100644 --- a/src/deps/facilio.zig +++ b/src/deps/facilio.zig @@ -58,7 +58,9 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti }; // TODO: BUG: without this print statement, -Drelease* loop forever // in debug2 and debug3 - std.debug.print("X\n", .{}); + // std.debug.print("X\n", .{}); + std.time.sleep(500 * 1000 * 1000); + if (C.http_listen(port, interface, x) == -1) { return error.ListenError; }