mirror of
https://git.robbyzambito.me/zaprus/
synced 2026-02-04 03:34:48 +00:00
Set timeouts instead of sleeping
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user