From 3dcbd43ecd77c28762b0595475893ff052c0444a Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 14 Oct 2024 18:29:15 -0600 Subject: wip libnet rewrite --- cmd/srv9p/main.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'cmd/srv9p/main.c') diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c index 94a00f7..4170b5d 100644 --- a/cmd/srv9p/main.c +++ b/cmd/srv9p/main.c @@ -2,11 +2,12 @@ #include #include -#include +#include #include #include "static9p.h" #include "static.h" +#include "gnet.h" /* configuration **************************************************************/ @@ -78,19 +79,28 @@ static struct lib9p_srv_file *get_root(struct lib9p_srv_ctx *UNUSED(ctx), char * /* main ***********************************************************************/ -int main() { - int sock = netio_listen(9000); - if (sock < 0) - error(1, -sock, "netio_listen"); +static COROUTINE read_cr(void *_srv) { + struct lib9p_srv *srv = _srv; + assert(srv); + + cr_begin(); + + struct gnet_listener listener; + gnet_listener_init(&listener, 9000); + + lib9p_srv_read_cr(srv, (struct libnet_listener *)&listener); + cr_end(); +} + +int main() { struct lib9p_srv srv = { - .sockfd = sock, .rootdir = get_root, }; for (int i = 0; i < CONFIG_NETIO_NUM_CONNS; i++) - if (!coroutine_add(lib9p_srv_read_cr, &srv)) - error(1, 0, "coroutine_add(lib9p_srv_read_cr, &srv)"); + if (!coroutine_add(read_cr, &srv)) + error(1, 0, "coroutine_add(read_cr, &srv)"); for (int i = 0; i < 2*CONFIG_NETIO_NUM_CONNS; i++) if (!coroutine_add(lib9p_srv_write_cr, &srv)) error(1, 0, "coroutine_add(lib9p_srv_write_cr, &srv)"); -- cgit v1.2.3-2-g168b