From ec1370b7fc78fc0fa69e60fefdd99028b860cb1d Mon Sep 17 00:00:00 2001 From: SPeak Date: Sun, 22 Sep 2024 13:19:34 +0800 Subject: [PATCH 1/2] bugfix: fwatcher: fix recursion detect issue for linux platform use -1 to set recursion limit(align to bsd-impl) Signed-off-by: SPeak --- src/tbox/platform/linux/fwatcher_inotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tbox/platform/linux/fwatcher_inotify.c b/src/tbox/platform/linux/fwatcher_inotify.c index ac4fb873b..9f0d89071 100644 --- a/src/tbox/platform/linux/fwatcher_inotify.c +++ b/src/tbox/platform/linux/fwatcher_inotify.c @@ -262,7 +262,7 @@ tb_bool_t tb_fwatcher_add(tb_fwatcher_ref_t self, tb_char_t const* watchdir, tb_ // is directory? we need scan it and add all subdirs if (info.type == TB_FILE_TYPE_DIRECTORY && recursion) - tb_directory_walk(watchdir, 0, tb_true, tb_fwatcher_add_watch_dirs, fwatcher); + tb_directory_walk(watchdir, -1, tb_true, tb_fwatcher_add_watch_dirs, fwatcher); return tb_fwatcher_add_watch(fwatcher, watchdir, recursion); } From 49e71d453c338f2e4a9a91b3521fa7ad30a335b3 Mon Sep 17 00:00:00 2001 From: SPeak Date: Sun, 22 Sep 2024 13:44:41 +0800 Subject: [PATCH 2/2] update --- src/tbox/platform/bsd/fwatcher_kqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tbox/platform/bsd/fwatcher_kqueue.c b/src/tbox/platform/bsd/fwatcher_kqueue.c index add8def06..bb7f68a17 100644 --- a/src/tbox/platform/bsd/fwatcher_kqueue.c +++ b/src/tbox/platform/bsd/fwatcher_kqueue.c @@ -304,8 +304,8 @@ tb_bool_t tb_fwatcher_add(tb_fwatcher_ref_t self, tb_char_t const* watchdir, tb_ return tb_false; // is directory? we need scan it and add all subfiles - if (info.type == TB_FILE_TYPE_DIRECTORY) - tb_directory_walk(watchdir, recursion? -1 : 0, tb_true, tb_fwatcher_add_watch_filedirs, fwatcher); + if (info.type == TB_FILE_TYPE_DIRECTORY && recursion) + tb_directory_walk(watchdir, -1, tb_true, tb_fwatcher_add_watch_filedirs, fwatcher); return tb_fwatcher_add_watch(fwatcher, watchdir, recursion); }