summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-13 21:41:59 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-14 11:59:02 -0600
commitd67fd84e5f5aa34d5ddad40355e05446bca00a37 (patch)
treee3e0d31143e44aa63c20e6768f428095555c3e74 /lib9p/srv.c
parenteb29f2c0dc2b818c49d3101666159056deb3f3fe (diff)
lib9p_srv: Require less compile-time config
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index c64f995..e664d0f 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -32,16 +32,6 @@
#include "config.h"
-#ifndef CONFIG_9P_SRV_MAX_FIDS
- #error config.h must define CONFIG_9P_SRV_MAX_FIDS
-#endif
-#ifndef CONFIG_9P_SRV_MAX_REQS
- #error config.h must define CONFIG_9P_SRV_MAX_REQS
-#endif
-#ifndef CONFIG_9P_SRV_MAX_DEPTH
- /* 1=just the root dir, 2=just files in the root dir, 3=1 subdir, ... */
- #error config.h must define CONFIG_9P_SRV_MAX_DEPTH
-#endif
#ifndef CONFIG_9P_SRV_MAX_MSG_SIZE
#error config.h must define CONFIG_9P_SRV_MAX_MSG_SIZE
#endif
@@ -249,14 +239,18 @@ static inline struct srv_pathinfo *srv_path_save(struct srv_req *ctx,
static inline void srv_path_decref(struct srv_req *ctx, srv_path_t path) {
assert(ctx);
- struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, path);
- assert(pathinfo);
- pathinfo->gc_refcount--;
- if (pathinfo->gc_refcount == 0) {
- if (pathinfo->parent_dir != path)
- srv_path_decref(ctx, pathinfo->parent_dir);
+ for (;;) {
+ struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, path);
+ assert(pathinfo);
+ pathinfo->gc_refcount--;
+ if (pathinfo->gc_refcount)
+ break;
+ srv_path_t parent_path = pathinfo->parent_dir;
LO_CALL(pathinfo->file, free);
map_del(&ctx->parent_sess->paths, path);
+ if (parent_path == path)
+ break;
+ path = parent_path;
}
}