-
-
Notifications
You must be signed in to change notification settings - Fork 125
Fix & Improve doc comment on some structures #167
Description
Fix staled comments on DirList, DirEntry, IntoIter
It's said that these structure relies on std::fs::DirEntry which is outdated since we use our crate::dent::DirEntry
Supply additional comment for difference between std DirEntry and our DirEntry
I've no idea if we've noticed that std DirEntry hold a reference of opened dir as the documented mentioned.
In a detail, on Unix implementaions:
ReadDir holds an Arc of InnerReadDir, and it shares it with DirEntry.
readdir
ReadDir
Impl Iterator for ReadDir
DirEntry
The InnderReadDir holds the Dir which is an wrapper of platform native opaque DIR.
DIR
When the InnerReadDir is dropped, it calls native closedir would close underlying fd associated.
impl Drop for Dir
closedir
https://man7.org/linux/man-pages/man3/closedir.3.html
https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/toc.htm
In other words, If we keep the DirEntry, the InnerReader inner Arc wouldn't be dropped, that's: directory fd wouldn't be released even through we drop ReadDir through max_open control ! So, we could encounter Too many open files error when using collect on the iteration when walking a big enough directory !
However, luckily, we use our impl DirEntry instead of std version since it doesnt hold the fd reference. We just need to document it as additional doc comment before our DirEntry!