[lxc-devel] [lxc/master] tree-wide: replace readdir_r() with readdir()

Christian Brauner christian.brauner at mailbox.org
Wed Aug 10 17:30:22 UTC 2016


On Wed, Aug 10, 2016 at 10:32:58AM -0500, Serge Hallyn wrote:
> No.
> 
> readdir is not thread-safe.  assuming that glibc has made readdir thread-safe
> and therefore deprecated readdir_r, then we have to work harder to be safe
> backward-compatible.

POSIX seems to require that multiple calls to readdir() on different directory
streams do not overwrite the returned buffer. This only seems to happen when
multiple threads read from the same directory stream. If this cannot be the case
we could just switch to readdir(), no? If we have a case in the codebase where
multiple threads could read from the same dir stream this becomes quite messy to
fix.


More information about the lxc-devel mailing list