summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-02 02:01:30 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-09 23:42:11 -0700
commit06eed899486daeec8ad2718c74d70f91fa0dbb25 (patch)
treef402d1cc1e82f5e297db142f51fdfd4306a74f68 /lib9p/srv.c
parentcb0c00a240c0d803e7202433f9940a91db849a5c (diff)
libhw_generic: net: Use libobj instead of vcall.h
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 47dd78d..0bfe5da 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -108,7 +108,7 @@ struct _srv_fidinfo {
struct _srv_conn {
/* immutable */
struct lib9p_srv *parent_srv;
- implements_net_stream_conn *fd;
+ lo_interface net_stream_conn fd;
cid_t reader; /* the lib9p_srv_read_cr() coroutine */
/* mutable */
cr_mutex_t writelock;
@@ -197,7 +197,7 @@ static void respond_error(struct _lib9p_srv_req *req) {
&host, req->net_bytes);
cr_mutex_lock(&sess->parent_conn->writelock);
- r = VCALL(sess->parent_conn->fd, write,
+ r = LO_CALL(sess->parent_conn->fd, write,
req->net_bytes, uint32le_decode(req->net_bytes));
cr_mutex_unlock(&sess->parent_conn->writelock);
if (r < 0)
@@ -206,12 +206,12 @@ static void respond_error(struct _lib9p_srv_req *req) {
/* read coroutine *************************************************************/
-static bool read_at_least(implements_net_stream_conn *fd, uint8_t *buf, size_t goal, size_t *done) {
+static bool read_at_least(lo_interface net_stream_conn fd, uint8_t *buf, size_t goal, size_t *done) {
assert(buf);
assert(goal);
assert(done);
while (*done < goal) {
- ssize_t r = VCALL(fd, read, &buf[*done], CONFIG_9P_MAX_MSG_SIZE - *done);
+ ssize_t r = LO_CALL(fd, read, &buf[*done], CONFIG_9P_MAX_MSG_SIZE - *done);
if (r < 0) {
nonrespond_errorf("read: %s", net_strerror(-r));
return true;
@@ -227,12 +227,12 @@ static bool read_at_least(implements_net_stream_conn *fd, uint8_t *buf, size_t g
static void handle_message(struct _lib9p_srv_req *ctx);
-[[noreturn]] void lib9p_srv_read_cr(struct lib9p_srv *srv, implements_net_stream_listener *listener) {
+[[noreturn]] void lib9p_srv_read_cr(struct lib9p_srv *srv, lo_interface net_stream_listener listener) {
uint8_t buf[CONFIG_9P_MAX_MSG_SIZE];
assert(srv);
assert(srv->rootdir);
- assert(listener);
+ assert(!LO_IS_NULL(listener));
srv->readers++;
@@ -241,10 +241,10 @@ static void handle_message(struct _lib9p_srv_req *ctx);
for (;;) {
struct _srv_conn conn = {
.parent_srv = srv,
- .fd = VCALL(listener, accept),
+ .fd = LO_CALL(listener, accept),
.reader = cr_getcid(),
};
- if (!conn.fd) {
+ if (LO_IS_NULL(conn.fd)) {
nonrespond_errorf("accept: error");
srv->readers--;
if (srv->readers == 0)
@@ -305,12 +305,12 @@ static void handle_message(struct _lib9p_srv_req *ctx);
_lib9p_srv_reqch_send_req(&srv->_reqch, &req);
}
close:
- VCALL(conn.fd, close, true, sess.reqs.len == 0);
+ LO_CALL(conn.fd, close, true, sess.reqs.len == 0);
if (sess.reqs.len) {
sess.closing = true;
cr_pause_and_yield();
assert(sess.reqs.len == 0);
- VCALL(conn.fd, close, true, true);
+ LO_CALL(conn.fd, close, true, true);
}
}
}
@@ -438,8 +438,8 @@ static void handle_message(struct _lib9p_srv_req *ctx) {
goto write;
cr_mutex_lock(&ctx->parent_sess->parent_conn->writelock);
- VCALL(ctx->parent_sess->parent_conn->fd, write,
- ctx->net_bytes, uint32le_decode(ctx->net_bytes));
+ LO_CALL(ctx->parent_sess->parent_conn->fd, write,
+ ctx->net_bytes, uint32le_decode(ctx->net_bytes));
cr_mutex_unlock(&ctx->parent_sess->parent_conn->writelock);
}
}