diff options
Diffstat (limited to 'cmd/srv9p/main.c')
-rw-r--r-- | cmd/srv9p/main.c | 26 |
1 files changed, 18 insertions, 8 deletions
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 <stdio.h> #include <libcr/coroutine.h> -#include <libnetio/netio.h> +#include <libnet/libnet.h> #include <lib9p/srv.h> #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)"); |