Skip to content

Commit c338eec

Browse files
authored
Merge pull request ceph#63605 from tchaikov/wip-rgw-sal-posix-fix-leak
rgw/driver/posix: closedir() to free dir handle Reviewed-by: Daniel Gryniewicz <[email protected]>
2 parents 452585e + b5bd466 commit c338eec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/rgw/driver/posix/rgw_sal_posix.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ static int delete_directory(int parent_fd, const char* dname, bool delete_childr
351351
return -ret;
352352
}
353353
}
354+
closedir(dir);
354355

355356
ret = unlinkat(parent_fd, dname, AT_REMOVEDIR);
356357
if (ret < 0) {
@@ -899,6 +900,13 @@ int Directory::for_each(const DoutPrefixProvider* dpp, const F& func)
899900
/* Limit reached */
900901
ret = 0;
901902
}
903+
904+
closedir(dir);
905+
// closedir() closes the fd, so we need to invalidate it
906+
fd = -1;
907+
// closedir() closes fd, but succeeding calls might assume that fd is still valid.
908+
// so let's reopen it.
909+
open(dpp);
902910
return ret;
903911
}
904912

0 commit comments

Comments
 (0)