summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-12 20:43:18 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-12 21:37:47 -0600
commitfc115b98c8c41e0e76319839c0227d8f44381394 (patch)
treef700f538566aea6d5eaa1412beaf65f2c2caf566 /lib9p/srv.c
parent6b6bc44e7948253f5793022aa6c1f3e3acdb348d (diff)
lib9p: Test+fix that io handles get freed
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c27
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 ************************************************************/