Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/api/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ pub const Server = struct {

// allow address reuse so we can restart quickly
const optval: c_int = 1;
posix.setsockopt(fd, posix.SOL.SOCKET, posix.SO.REUSEADDR, std.mem.asBytes(&optval)) catch {};
posix.setsockopt(fd, posix.SOL.SOCKET, posix.SO.REUSEADDR, std.mem.asBytes(&optval)) catch |e| {
log.warn("api server failed to set SO_REUSEADDR: {}", .{e});
};

const addr = std.net.Address.initIp4(bind_addr, port);
posix.bind(fd, &addr.any, addr.getOsSockLen()) catch return ServerError.BindFailed;
Expand Down
4 changes: 3 additions & 1 deletion src/api/server/connection_runtime.zig
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ pub fn findHeaderEnd(buf: []const u8) ?usize {

fn setReadTimeout(fd: posix.fd_t, seconds: i64) void {
const timeout = posix.timeval{ .sec = seconds, .usec = 0 };
posix.setsockopt(fd, posix.SOL.SOCKET, posix.SO.RCVTIMEO, std.mem.asBytes(&timeout)) catch {};
posix.setsockopt(fd, posix.SOL.SOCKET, posix.SO.RCVTIMEO, std.mem.asBytes(&timeout)) catch |e| {
log.warn("api server failed to set read timeout: {}", .{e});
};
}

fn sendError(fd: posix.fd_t, status: http.StatusCode, message: []const u8) void {
Expand Down
4 changes: 3 additions & 1 deletion src/gpu/passthrough.zig
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ fn writeCgroupFile(cgroup_path: []const u8, filename: []const u8, value: []const
const file_path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ cgroup_path, filename }) catch return;
const file = std.fs.cwd().openFile(file_path, .{ .mode = .write_only }) catch return;
defer file.close();
file.writeAll(value) catch {};
file.writeAll(value) catch |e| {
log.warn("gpu cgroup write failed for {s}/{s}: {}", .{ cgroup_path, filename, e });
};
}

fn ensureContainerDevDir(merged_dir: []const u8) !void {
Expand Down
8 changes: 6 additions & 2 deletions src/manifest/update/batch_runtime.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pub fn handleBatchFailure(
progress.message = reason;

if (deployment_id) |id| {
deployment_store.updateDeploymentStatus(id, .rolled_back, reason) catch {};
deployment_store.updateDeploymentStatus(id, .rolled_back, reason) catch |e| {
log.warn("failed to update deployment status to rolled_back: {}", .{e});
};
}

return common.UpdateError.BatchFailed;
Expand All @@ -35,7 +37,9 @@ pub fn handleBatchFailure(
progress.message = reason;

if (deployment_id) |id| {
deployment_store.updateDeploymentStatus(id, .failed, reason) catch {};
deployment_store.updateDeploymentStatus(id, .failed, reason) catch |e| {
log.warn("failed to update deployment status to failed: {}", .{e});
};
}

return common.UpdateError.UpdatePaused;
Expand Down
4 changes: 3 additions & 1 deletion src/tls/challenge_server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ pub const ChallengeServer = struct {
key_auth.len,
key_auth,
}) catch return;
_ = posix.write(client_fd, response) catch {};
_ = posix.write(client_fd, response) catch |e| {
log.warn("acme challenge response write failed: {}", .{e});
};
}
};
8 changes: 6 additions & 2 deletions src/tls/proxy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ pub const TlsProxy = struct {

var response_buf: [1024]u8 = undefined;
const response = http_support.formatRedirectResponse(&response_buf, location) catch return;
_ = posix.write(client_fd, response) catch {};
_ = posix.write(client_fd, response) catch |e| {
log.warn("tls proxy redirect write failed: {}", .{e});
};
}

fn serveAcmeChallenge(self: *TlsProxy, client_fd: posix.fd_t, token: []const u8) void {
Expand All @@ -477,7 +479,9 @@ pub const TlsProxy = struct {

var response_buf: [1024]u8 = undefined;
const response = std.fmt.bufPrint(&response_buf, "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: {d}\r\nConnection: close\r\n\r\n{s}", .{ key_auth.len, key_auth }) catch return;
_ = posix.write(client_fd, response) catch {};
_ = posix.write(client_fd, response) catch |e| {
log.warn("tls proxy acme challenge write failed: {}", .{e});
};
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/tls/proxy/http_support.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const posix = std.posix;
const log = @import("../../lib/log.zig");

pub fn extractHost(request: []const u8) ?[]const u8 {
const headers = headerBlock(request) orelse return null;
Expand Down Expand Up @@ -83,13 +84,17 @@ pub fn sendCloseNotify(fd: posix.fd_t) void {
0x01,
0x00,
};
_ = posix.write(fd, &close_notify) catch {};
_ = posix.write(fd, &close_notify) catch |e| {
log.warn("tls close_notify write failed: {}", .{e});
};
}

pub fn sendHttpResponse(fd: posix.fd_t, status: []const u8, body: []const u8) void {
var buf: [512]u8 = undefined;
const response = std.fmt.bufPrint(&buf, "HTTP/1.1 {s}\r\nContent-Length: {d}\r\nConnection: close\r\n\r\n{s}", .{ status, body.len, body }) catch return;
_ = posix.write(fd, response) catch {};
_ = posix.write(fd, response) catch |e| {
log.warn("tls http response write failed: {}", .{e});
};
}

pub fn formatRedirectResponse(
Expand Down
6 changes: 5 additions & 1 deletion src/tls/proxy/session_runtime.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const posix = std.posix;
const log = @import("../../lib/log.zig");
const http2_request = @import("../../network/proxy/http2_request.zig");
const backend_mod = @import("../backend.zig");
const handshake = @import("../handshake.zig");
Expand Down Expand Up @@ -334,7 +335,10 @@ pub fn sendEncryptedCloseNotify(fd: posix.fd_t, keys: handshake.TrafficKeys, seq
var out: [5 + 64]u8 = undefined;
record.writeHeader(&out, .application_data, @intCast(ct_len)) catch return;
@memcpy(out[5 .. 5 + ct_len], ct_buf[0..ct_len]);
_ = posix.write(fd, out[0 .. 5 + ct_len]) catch {};
_ = posix.write(fd, out[0 .. 5 + ct_len]) catch |e| {
log.warn("tls encrypted data write failed: {}", .{e});
return;
};
seq.* += 1;
}

Expand Down
Loading