Skip to content

Commit

Permalink
Be more consistent with async/await coro suspension/error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed Jun 20, 2024
1 parent be71406 commit 18a3e13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/lwan-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ static int prepare_awaitv(struct lwan_request *r,

*state = (struct awaitv_state){
.num_awaiting = 0,
.request_conn_yield = CONN_CORO_YIELD,
.request_conn_yield = CONN_CORO_SUSPEND,
};

clear_awaitv_flags(l->conns, ap);
Expand Down Expand Up @@ -817,8 +817,12 @@ int lwan_request_awaitv_all(struct lwan_request *r, ...)
int ret = prepare_awaitv(r, l, ap, &state);
va_end(ap);

if (UNLIKELY(ret < 0))
return ret;
if (UNLIKELY(ret < 0)) {
errno = -ret;
lwan_status_perror("prepare_awaitv()");
coro_yield(r->conn->coro, CONN_CORO_ABORT);
__builtin_unreachable();
}

while (state.num_awaiting) {
int64_t v = coro_yield(r->conn->coro, state.request_conn_yield);
Expand Down

0 comments on commit 18a3e13

Please sign in to comment.