diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 5660f08..5ff083f 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -182,7 +182,7 @@ static void respond_error(struct _lib9p_srv_req *req) { struct lib9p_msg_Rerror host = { .tag = req->tag, .errstr = lib9p_strn(req->ctx.basectx.err_msg, - CONFIG_9P_MAX_ERR_SIZE), + CONFIG_9P_MAX_ERR_SIZE), #if CONFIG_9P_ENABLE_9P2000_u .errnum = req->ctx.basectx.err_num, #endif @@ -251,6 +251,8 @@ void lib9p_srv_accept_and_read_loop(struct lib9p_srv *srv, lo_interface net_stre } } +static void clunkremove(struct _lib9p_srv_req *ctx, lib9p_fid_t fid, bool remove); + void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) { assert(srv); assert(srv->rootdir); @@ -326,9 +328,28 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) { assert(map_len(&sess.reqs) == 0); io_close_write(conn.fd); } - map_free(&sess.paths); - map_free(&sess.fids); + + assert(map_len(&sess.reqs) == 0); map_free(&sess.reqs); + + MAP_FOREACH(&sess.fids, fid, fidinfo) { + struct _lib9p_srv_req req = { + .parent_sess = &sess, + .ctx = { + .basectx = { + .version = sess.version, + .max_msg_size = sess.max_msg_size, + }, + }, + }; + clunkremove(&req, fid, false); + if (lib9p_ctx_has_error(&req.ctx.basectx)) + errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, req.ctx.basectx.err_msg); + } + map_free(&sess.fids); + + assert(map_len(&sess.paths) == 0); + map_free(&sess.paths); } /* write coroutine ************************************************************/ |