diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-02 02:01:30 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-09 23:42:11 -0700 |
commit | 06eed899486daeec8ad2718c74d70f91fa0dbb25 (patch) | |
tree | f402d1cc1e82f5e297db142f51fdfd4306a74f68 /lib9p | |
parent | cb0c00a240c0d803e7202433f9940a91db849a5c (diff) |
libhw_generic: net: Use libobj instead of vcall.h
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/include/lib9p/srv.h | 2 | ||||
-rw-r--r-- | lib9p/srv.c | 24 | ||||
-rw-r--r-- | lib9p/tests/test_server/main.c | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index e9d2d7b..0fc9011 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -105,7 +105,7 @@ struct lib9p_srv { * @errno LINUX_ERANGE R-message does not fit into max_msg_size */ -[[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); COROUTINE lib9p_srv_write_cr(void *_srv); #endif /* _LIB9P_SRV_H_ */ 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); } } diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index 8df3da0..6655f67 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -91,7 +91,7 @@ static uint32_t api_pwrite(implements_lib9p_srv_file *, struct lib9p_srv_ctx *, if (byte_count == 0) return 0; for (int i = 0; i < CONFIG_SRV9P_NUM_CONNS; i++) - VCALL(&globals.listeners[i], close); + LO_CALL(lo_box_hostnet_tcplist_as_net_stream_listener(&globals.listeners[i]), close); return byte_count; } @@ -170,7 +170,7 @@ static COROUTINE read_cr(void *_i) { hostnet_tcp_listener_init(&globals.listeners[i], 9000); - lib9p_srv_read_cr(&globals.srv, &globals.listeners[i]); + lib9p_srv_read_cr(&globals.srv, lo_box_hostnet_tcplist_as_net_stream_listener(&globals.listeners[i])); cr_end(); } |