diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-04 09:05:14 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-04 21:01:49 -0700 |
commit | 57d4c9f154cacd5d0dcc2f45033d784b3e0b6734 (patch) | |
tree | f96f5c57bbb042b3962bed49853621f6d344de04 /lib9p/srv.c | |
parent | 635539cd0da713729ec2852b3691dc9f73734e59 (diff) |
lib9p: Test that we can do clean shutdown
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 7e6402e..10a8a96 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -200,6 +200,8 @@ static void handle_message(struct _lib9p_srv_req *ctx); assert(srv->rootdir); assert(listener); + srv->readers++; + uint32_t initial_rerror_overhead = rerror_overhead_for_version(0, buf); for (;;) { @@ -210,7 +212,11 @@ static void handle_message(struct _lib9p_srv_req *ctx); }; if (!conn.fd) { nonrespond_errorf("accept: error"); - continue; + srv->readers--; + if (srv->readers == 0) + while (srv->writers > 0) + _lib9p_srv_reqch_send_req(&srv->_reqch, NULL); + cr_exit(); } struct _srv_sess sess = { @@ -287,9 +293,16 @@ COROUTINE lib9p_srv_write_cr(void *_srv) { assert(srv->rootdir); cr_begin(); + srv->writers++; + for (;;) { /* Receive the request from the reader coroutine. ************/ rpc_handle = _lib9p_srv_reqch_recv_req(&srv->_reqch); + if (!rpc_handle.req) { + srv->writers--; + _lib9p_srv_reqch_send_resp(rpc_handle, 0); + cr_exit(); + } /* Deep-copy the request from the reader coroutine's * stack to our stack. */ req = *rpc_handle.req; |