mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
don't try (and fail) to get userData after clearing context
This commit is contained in:
@@ -73,54 +73,55 @@ pub const LightPanda = struct {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleError(self: *LightPanda, ctx: *Client.Ctx, err: anyerror) anyerror!void {
|
fn handleError(sending: *Sending, ctx: *Client.Ctx, err: anyerror) anyerror!void {
|
||||||
ctx.deinit();
|
const lightpanda = sending.lightpanda;
|
||||||
self.client_context_pool.destroy(ctx);
|
|
||||||
|
ctx.deinit();
|
||||||
|
lightpanda.client_context_pool.destroy(ctx);
|
||||||
|
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
|
||||||
sending.deinit();
|
sending.deinit();
|
||||||
self.sending_pool.destroy(sending);
|
lightpanda.sending_pool.destroy(sending);
|
||||||
log.info("request failure: {}", .{err});
|
log.info("request failure: {}", .{err});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onRequestConnect(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
fn onRequestConnect(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
const sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
||||||
res catch |err| return sending.lightpanda.handleError(ctx, err);
|
res catch |err| return handleError(sending, ctx, err);
|
||||||
|
|
||||||
ctx.req.transfer_encoding = .{ .content_length = sending.body.len };
|
ctx.req.transfer_encoding = .{ .content_length = sending.body.len };
|
||||||
return ctx.req.async_send(ctx, onRequestSend) catch |err| {
|
return ctx.req.async_send(ctx, onRequestSend) catch |err| {
|
||||||
return sending.lightpanda.handleError(ctx, err);
|
return handleError(sending, ctx, err);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onRequestSend(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
fn onRequestSend(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
const sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
||||||
res catch |err| return sending.lightpanda.handleError(ctx, err);
|
res catch |err| return handleError(sending, ctx, err);
|
||||||
|
|
||||||
return ctx.req.async_writeAll(sending.body, ctx, onRequestWrite) catch |err| {
|
return ctx.req.async_writeAll(sending.body, ctx, onRequestWrite) catch |err| {
|
||||||
return sending.lightpanda.handleError(ctx, err);
|
return handleError(sending, ctx, err);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onRequestWrite(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
fn onRequestWrite(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
const sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
||||||
res catch |err| return sending.lightpanda.handleError(ctx, err);
|
res catch |err| return handleError(sending, ctx, err);
|
||||||
return ctx.req.async_finish(ctx, onRequestFinish) catch |err| {
|
return ctx.req.async_finish(ctx, onRequestFinish) catch |err| {
|
||||||
return sending.lightpanda.handleError(ctx, err);
|
return handleError(sending, ctx, err);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onRequestFinish(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
fn onRequestFinish(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
const sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
||||||
res catch |err| return sending.lightpanda.handleError(ctx, err);
|
res catch |err| return handleError(sending, ctx, err);
|
||||||
return ctx.req.async_wait(ctx, onRequestWait) catch |err| {
|
return ctx.req.async_wait(ctx, onRequestWait) catch |err| {
|
||||||
return sending.lightpanda.handleError(ctx, err);
|
return handleError(sending, ctx, err);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onRequestWait(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
fn onRequestWait(ctx: *Client.Ctx, res: anyerror!void) anyerror!void {
|
||||||
var sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
const sending: *Sending = @ptrCast(@alignCast(ctx.userData));
|
||||||
res catch |err| return sending.lightpanda.handleError(ctx, err);
|
res catch |err| return handleError(sending, ctx, err);
|
||||||
|
|
||||||
const lightpanda = sending.lightpanda;
|
const lightpanda = sending.lightpanda;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const log = std.log.scoped(.telemetry);
|
|||||||
const ID_FILE = "lightpanda.id";
|
const ID_FILE = "lightpanda.id";
|
||||||
|
|
||||||
pub const Telemetry = TelemetryT(blk: {
|
pub const Telemetry = TelemetryT(blk: {
|
||||||
if (builtin.mode == .Debug or builtin.is_test) break :blk NoopProvider;
|
// if (builtin.mode == .Debug or builtin.is_test) break :blk NoopProvider;
|
||||||
break :blk @import("lightpanda.zig").LightPanda;
|
break :blk @import("lightpanda.zig").LightPanda;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user