Skip to content

Commit

Permalink
Some refinements and additions (#565)
Browse files Browse the repository at this point in the history
* Fixes a lock guard leak in certain codepaths.
* Refactors the linux io_uring backend `Entry` definition to properly
  allow for more than just the `ACCEPT` alt allocationless state.
* Flushes headers in the basic server preemptively.
* Factor out http version into a constant in linux io_uring backend.
* Handle `/health` route, returning skeleton "unknown".
* Add skeleton tag for handling genesis file requests.
  • Loading branch information
InKryption authored Feb 14, 2025
1 parent 50a4f20 commit 01859bb
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 115 deletions.
19 changes: 17 additions & 2 deletions src/rpc/server/basic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub fn acceptAndServeConnection(server_ctx: *server.Context) !void {
.content_length = archive_len,
.respond_options = .{},
});
// flush the headers, so that if this is a head request, we can mock the response without doing unnecessary work
try response.flush();

if (!response.elide_body) {
// use a length which is still a multiple of 2, greater than the send_buffer length,
Expand Down Expand Up @@ -97,18 +99,31 @@ pub fn acceptAndServeConnection(server_ctx: *server.Context) !void {
try response.end();
return;
},
.unrecognized => {},
.health => {
try request.respond("unknown", .{
.status = .ok,
.keep_alive = false,
});
return;
},

.genesis_file => {},

.not_found => {},
},
.POST => {
logger.err().logf("{} tried to invoke our RPC", .{conn_address});
return try request.respond("RPCs are not yet implemented", .{
try request.respond("RPCs are not yet implemented", .{
.status = .service_unavailable,
.keep_alive = false,
});
return;
},
else => {},
}

// fallthrough to 404 Not Found

logger.err().logf(
"{} made an unrecognized request '{} {s}'",
.{ conn_address, requests.methodFmt(request.head.method), request.head.target },
Expand Down
Loading

0 comments on commit 01859bb

Please sign in to comment.