parsing cleanup

This commit is contained in:
2026-01-09 15:43:40 -05:00
parent f4b545f852
commit 0ebc39b5e8
2 changed files with 64 additions and 62 deletions

View File

@@ -195,7 +195,7 @@ fn handleConnection(
// Respond to ping with pong.
try client.recv_queue_write_lock.lock(io);
defer client.recv_queue_write_lock.unlock(io);
_ = try client.from_client.take(2);
_ = try client.from_client.take(2); // throw out \r\n
try client.recv_queue.putAll(io, "PONG\r\n");
},
.PUB => {
@@ -355,13 +355,12 @@ fn publishMessage(
},
else => {},
}
try line_writer.print("{d}\r\n", .{msg.payload.len});
try line_writer.print("{d}\r\n", .{msg.payload.len - 2});
try subscription.queue_lock.lock(io);
defer subscription.queue_lock.unlock(io);
try subscription.queue.putAll(io, line_writer.buffered());
try subscription.queue.putAll(io, msg.payload);
try subscription.queue.putAll(io, "\r\n");
}
}
@@ -426,7 +425,7 @@ fn unsubscribe(
/// Try to match the kernel socket buffers to maximize
/// the amount of data we push through each syscall.
fn getBufferSizes(io: Io) @Tuple(&.{ usize, usize }) {
const default_size = 4 * 1024;
const default_size = 8 * 1024 * 1024;
const default = .{ default_size, default_size };
const dir = Dir.openDirAbsolute(io, "/proc/sys/net/core", .{}) catch {