mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
cdp: send I/O next read before executing current cmd
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -128,17 +128,6 @@ pub const Ctx = struct {
|
||||
return;
|
||||
}
|
||||
|
||||
// input
|
||||
const input = self.read_buf[0..size];
|
||||
|
||||
// read and execute input
|
||||
self.msg_buf.read(self.alloc(), input, self, Ctx.do) catch |err| {
|
||||
if (err != error.Closed) {
|
||||
log.err("do error: {any}", .{err});
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
// set connection timestamp
|
||||
self.last_active = std.time.Instant.now() catch |err| {
|
||||
log.err("read timestamp error: {any}", .{err});
|
||||
@@ -154,6 +143,26 @@ pub const Ctx = struct {
|
||||
self.conn_socket,
|
||||
self.read_buf,
|
||||
);
|
||||
|
||||
// read and execute input
|
||||
var input: []const u8 = self.read_buf[0..size];
|
||||
while (input.len > 0) {
|
||||
const parts = self.msg_buf.read(self.alloc(), input) catch |err| {
|
||||
if (err == error.MsgMultipart) {
|
||||
return;
|
||||
} else {
|
||||
log.err("msg read error: {any}", .{err});
|
||||
return;
|
||||
}
|
||||
};
|
||||
input = parts.left;
|
||||
// execute
|
||||
self.do(parts.msg) catch |err| {
|
||||
if (err != error.Closed) {
|
||||
log.err("do error: {any}", .{err});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn timeoutCbk(self: *Ctx, completion: *Completion, result: TimeoutError!void) void {
|
||||
|
||||
Reference in New Issue
Block a user