From d67fd84e5f5aa34d5ddad40355e05446bca00a37 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 13 Apr 2025 21:41:59 -0600 Subject: lib9p_srv: Require less compile-time config --- lib9p/srv.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'lib9p/srv.c') 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; } } -- cgit v1.2.3-2-g168b