You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
minghu6
changed the title
Fix & Improve doc comment on some structure
Fix & Improve doc comment on some structures
Aug 21, 2022
Fix staled comments on
DirList
,DirEntry
,IntoIter
It's said that these structure relies on
std::fs::DirEntry
which is outdated since we use ourcrate::dent::DirEntry
Supply additional comment for difference between std
DirEntry
and ourDirEntry
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 ofInnerReadDir
, and it shares it withDirEntry
.readdir
ReadDir
Impl Iterator for ReadDir
DirEntry
The
InnderReadDir
holds theDir
which is an wrapper of platform native opaqueDIR
.DIR
When the
InnerReadDir
is dropped, it calls nativeclosedir
would close underlying fd associated.impl Drop for Dir
closedir
In other words, If we keep the
DirEntry
, theInnerReader
innerArc
wouldn't be dropped, that's: directory fd wouldn't be released even through we dropReadDir
throughmax_open
control ! So, we could encounterToo many open files
error when usingcollect
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 ourDirEntry
!The text was updated successfully, but these errors were encountered: