Skip to content

Commit 5cb0c3c

Browse files
committed
add test server timeout
1 parent 3e146f1 commit 5cb0c3c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/aws.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,10 +1588,11 @@ const TestOptions = struct {
15881588
return error.HeaderOrValueNotFound;
15891589
}
15901590
fn waitForReady(self: *Self) !void {
1591-
// While this doesn't return an error, we can use !void
1592-
// to prepare for addition of timeout
1593-
while (!self.server_ready)
1591+
// Set 1 minute timeout...this is way longer than necessary
1592+
var remaining_iters: isize = std.time.ns_per_min / 100;
1593+
while (!self.server_ready and remaining_iters > 0) : (remaining_iters -= 1)
15941594
std.time.sleep(100);
1595+
if (!self.server_ready) return error.TestServerTimeoutWaitingForReady;
15951596
}
15961597
};
15971598

@@ -1619,6 +1620,7 @@ fn threadMain(options: *TestOptions) !void {
16191620
// var aa = arena.allocator();
16201621
// We're in control of all requests/responses, so this flag will tell us
16211622
// when it's time to shut down
1623+
defer options.server_ready = true; // In case remaining_requests = 0, we don't want to wait forever
16221624
while (options.server_remaining_requests > 0) {
16231625
options.server_remaining_requests -= 1;
16241626
processRequest(options, &http_server) catch |e| {

0 commit comments

Comments
 (0)