From a38be0d32ac34b01996d4aeb871f68cf5cf09a5f Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 14 Dec 2024 15:00:20 +0300 Subject: [PATCH] fix lfn ff handle leak deltree must restart ff on backtrack in SFN mode - see 7e3365bd. In LFN mode there are ff handles that require findnext() until completion, or they are leaked. So close them explicitly. Regression of 7e3365bd - LFNs were not enabled back then. Note: it is possible to special-case LFN mode and not restart ff, relying on open handles. But this means coding difference with SFN mode, and also there may be insufficient ff handles in a redirector to traverse the large dir tree. --- src/command.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/command.c b/src/command.c index cb1868d..0e6e1c4 100644 --- a/src/command.c +++ b/src/command.c @@ -2419,6 +2419,17 @@ static void perform_deltree(const char *arg) } if (subdir_level > 0 || remove_level1_dir) { + /* Close cur dir when entering next level. We need this + * for 2 reasons: + * 1. In SFN mode there are no handles, so ff process needs + * to be restarted on backtrack (see 7e3365bd). + * To unify with LFN mode, we restart in both cases. + * 2. Even special-casing LFN mode may not be safe as it + * has the limited amount of ff handles. + * So just close handle and restart later. For SFN, close + * is a no-op. + */ + findclose_f(ffhandle); subdir_level++; if (subdir_level >= MAX_SUBDIR_LEVEL) {