diff options
| author | Robby Zambito <contact@robbyzambito.me> | 2026-01-24 20:56:37 -0500 |
|---|---|---|
| committer | Robby Zambito <contact@robbyzambito.me> | 2026-01-24 21:14:40 -0500 |
| commit | 3c5f34d5c2dafb4829becada1f0c6fb09d33ea79 (patch) | |
| tree | ade87c1e088c7d3b2292a09dcbc148ff6134f967 /src/main.zig | |
| parent | 09152377ed537c9b262e6b0a66a8ce88ca2619ad (diff) | |
Set timeouts instead of sleeping
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig index 708ad18..439dc93 100644 --- a/src/main.zig +++ b/src/main.zig @@ -127,8 +127,6 @@ pub fn main(init: std.process.Init) !void { return; } - var retry_seconds: u16 = 12 * if (is_debug) 1 else 10; - var init_con_buf: [SaprusClient.max_payload_len]u8 = undefined; var w: Writer = .fixed(&init_con_buf); try w.print("{b64}", .{flags.connect.?}); @@ -139,19 +137,18 @@ pub fn main(init: std.process.Init) !void { defer client.deinit(); log.debug("Starting connection", .{}); + try client.socket.setTimeout(if (is_debug) 3 else 25, 0); var connection = client.connect(init.io, w.buffered()) catch { - try init.io.sleep(.fromSeconds(retry_seconds), .boot); + log.debug("Connection timed out", .{}); continue; }; - retry_seconds = 60 * if (is_debug) 1 else 10; - log.debug("Connection started", .{}); next_message: while (true) { var res_buf: [2048]u8 = undefined; + try client.socket.setTimeout(if (is_debug) 60 else 600, 0); const next = connection.next(init.io, &res_buf) catch { - try init.io.sleep(.fromSeconds(retry_seconds), .boot); continue :reconnect; }; |
