It was impossible to distinguish between a nonempty batch of dirents
that contains all deleted entries (d.ino == 0) and a terminal batch
of dirents (size == 0). To fix this, we modify the getdents /
getdirentries interfaces to return nil, nil in the terminal case.
This is an incompatible change, but most users are probably using
the util.ls or util.dirtable methods.
The util.ls method left the directory FD open, to be later closed by
GC. This can lead to running out of FDs if GC doesn't happen soon
enough. The fix is to close the directory fd after the iterator
terminates normally, in addition to closing the fd in error cases.
This commit fixes two bugs:
It was impossible to distinguish between a nonempty batch of dirents that contains all deleted entries (d.ino == 0) and a terminal batch of dirents (size == 0). To fix this, we modify the getdents / getdirentries interfaces to return nil, nil in the terminal case. This is an incompatible change, but most users are probably using the util.ls or util.dirtable methods.
The util.ls method left the directory FD open, to be later closed by GC. This can lead to running out of FDs if GC doesn't happen soon enough. The fix is to close the directory fd after the iterator terminates normally, in addition to closing the fd in error cases.