Set timeouts instead of sleeping

This commit is contained in:
2026-01-24 20:56:37 -05:00
parent 09152377ed
commit 3c5f34d5c2
3 changed files with 10 additions and 12 deletions

View File

@@ -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;
};