Skip to content

Commit

Permalink
fix lfn ff handle leak
Browse files Browse the repository at this point in the history
deltree must restart ff on backtrack in SFN mode - see 7e3365b.
In LFN mode there are ff handles that require findnext() until
completion, or they are leaked. So close them explicitly.

Regression of 7e3365b - 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.
  • Loading branch information
stsp committed Dec 14, 2024
1 parent 1b23a6c commit a38be0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit a38be0d

Please sign in to comment.