Skip to content

Commit

Permalink
fix(router): prevent double close on file send failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mookums committed Nov 16, 2024
1 parent 5877d79 commit df3e16b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/http/router.zig
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn Router(comptime Server: type) type {

// Set file size.
provision.file_size = stat.size;
log.err("file size: {d}", .{provision.file_size});
log.debug("file size: {d}", .{provision.file_size});

// generate the etag and attach it to the response.
var hash = std.hash.Wyhash.init(0);
Expand Down Expand Up @@ -134,7 +134,6 @@ pub fn Router(comptime Server: type) type {

if (!success) {
log.warn("starting file stream failed!", .{});
try provision.context.close();
return;
}

Expand Down Expand Up @@ -188,7 +187,6 @@ pub fn Router(comptime Server: type) type {
if (!success) {
log.warn("send file stream failed!", .{});
std.posix.close(provision.fd);
try provision.context.close();
return;
}

Expand Down

0 comments on commit df3e16b

Please sign in to comment.