Skip to content

Commit

Permalink
s/CONN_ASYNC_AWAIT_MULTIPLE/CONN_ASYNC_AWAITV/g
Browse files Browse the repository at this point in the history
Makes this more consistent with the API names I ended up using.
  • Loading branch information
lpereira committed May 9, 2024
1 parent 92b4ec7 commit c26a398
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions src/lib/lwan-thread.c
Expand Up @@ -620,9 +620,9 @@ static void unasync_await_conn(void *data1, void *data2)
struct lwan_connection *async_fd_conn = data1;

async_fd_conn->flags &=
~(CONN_ASYNC_AWAIT | CONN_HUNG_UP | CONN_ASYNC_AWAIT_MULTIPLE);
~(CONN_ASYNC_AWAIT | CONN_HUNG_UP | CONN_ASYNC_AWAITV);
assert(async_fd_conn->parent);
async_fd_conn->parent->flags &= ~CONN_ASYNC_AWAIT_MULTIPLE;
async_fd_conn->parent->flags &= ~CONN_ASYNC_AWAITV;

async_fd_conn->thread = data2;

Expand Down Expand Up @@ -705,8 +705,8 @@ struct flag_update {
enum lwan_connection_coro_yield request_conn_yield;
};

static void reset_conn_async_await_multiple_flag(struct lwan_connection *conns,
va_list ap_orig)
static void reset_conn_async_awaitv_flag(struct lwan_connection *conns,
va_list ap_orig)
{
va_list ap;

Expand All @@ -719,7 +719,7 @@ static void reset_conn_async_await_multiple_flag(struct lwan_connection *conns,
break;
}

conns[await_fd].flags &= ~CONN_ASYNC_AWAIT_MULTIPLE;
conns[await_fd].flags &= ~CONN_ASYNC_AWAITV;

LWAN_NO_DISCARD(va_arg(ap, enum lwan_connection_coro_yield));
}
Expand All @@ -732,7 +732,7 @@ update_flags_for_async_awaitv(struct lwan_request *r, struct lwan *l, va_list ap
struct flag_update update = {.num_awaiting = 0,
.request_conn_yield = CONN_CORO_YIELD};

reset_conn_async_await_multiple_flag(l->conns, ap);
reset_conn_async_awaitv_flag(l->conns, ap);

while (true) {
int await_fd = va_arg(ap, int);
Expand All @@ -751,13 +751,13 @@ update_flags_for_async_awaitv(struct lwan_request *r, struct lwan *l, va_list ap

struct lwan_connection *conn = &l->conns[await_fd];

if (UNLIKELY(conn->flags & CONN_ASYNC_AWAIT_MULTIPLE)) {
if (UNLIKELY(conn->flags & CONN_ASYNC_AWAITV)) {
lwan_status_debug("ignoring second awaitv call on same fd: %d",
await_fd);
continue;
}

conn->flags |= CONN_ASYNC_AWAIT_MULTIPLE;
conn->flags |= CONN_ASYNC_AWAITV;
update.num_awaiting++;

if (await_fd == r->fd) {
Expand Down Expand Up @@ -793,7 +793,7 @@ int lwan_request_awaitv_any(struct lwan_request *r, ...)
int64_t v = coro_yield(r->conn->coro, update.request_conn_yield);
struct lwan_connection *conn = (struct lwan_connection *)(uintptr_t)v;

if (conn->flags & CONN_ASYNC_AWAIT_MULTIPLE)
if (conn->flags & CONN_ASYNC_AWAITV)
return lwan_connection_get_fd(l, conn);
}
}
Expand All @@ -811,8 +811,8 @@ void lwan_request_awaitv_all(struct lwan_request *r, ...)
int64_t v = coro_yield(r->conn->coro, update.request_conn_yield);
struct lwan_connection *conn = (struct lwan_connection *)(uintptr_t)v;

if (conn->flags & CONN_ASYNC_AWAIT_MULTIPLE) {
conn->flags &= ~CONN_ASYNC_AWAIT_MULTIPLE;
if (conn->flags & CONN_ASYNC_AWAITV) {
conn->flags &= ~CONN_ASYNC_AWAITV;
update.num_awaiting--;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/lib/lwan.h
Expand Up @@ -286,24 +286,24 @@ enum lwan_connection_flags {
* whenever associated client connection is closed. */
CONN_ASYNC_AWAIT = 1 << 8,

CONN_SENT_CONNECTION_HEADER = 1 << 9,
/* Used to both implement lwan_request_awaitv_all() correctly, and to
* ensure that spurious resumes from fds that weren't in the multiple
* await call won't return to the request handler. */
CONN_ASYNC_AWAITV = 1 << 9,

CONN_SENT_CONNECTION_HEADER = 1 << 10,

/* Is this a TLS connection? */
CONN_TLS = 1 << 10,
CONN_TLS = 1 << 11,

/* Both are used to know if an epoll event pertains to a listener rather
* than a client. */
CONN_LISTENER = 1 << 11,
CONN_LISTENER = 1 << 12,

/* Only valid when CONN_ASYNC_AWAIT is set. Set on file descriptors that
* got (EPOLLHUP|EPOLLRDHUP) events from epoll so that request handlers
* can deal with this fact. */
CONN_HUNG_UP = 1 << 12,

/* Used to both implement lwan_request_awaitv_all() correctly, and to
* ensure that spurious resumes from fds that weren't in the multiple
* await call won't return to the request handler. */
CONN_ASYNC_AWAIT_MULTIPLE = 1 << 13,
CONN_HUNG_UP = 1 << 13,

CONN_FLAG_LAST = CONN_HUNG_UP,
};
Expand Down

0 comments on commit c26a398

Please sign in to comment.