[libvirt] PATCH: 15/25: Prohibit non-threadsafe POSIX apis

Richard W.M. Jones rjones at redhat.com
Fri Jan 16 13:05:13 UTC 2009


On Tue, Jan 13, 2009 at 05:44:51PM +0000, Daniel P. Berrange wrote:
> The readdir one is also unneccessary, since reading from a single
> DIR* is safe from a single thread. readdir_r is also horrific
> 
> http://womble.decadentplace.org.uk/readdir_r-advisory.html

That web page also says that readdir isn't thread safe, in that an
implementation could still use some global state (outside of the
DIR*):

<quote>
  Programs using readdir_r may be able to use readdir. According to
  POSIX the buffer readdir uses is not shared between directory
  streams. However readdir is not guaranteed to be thread-safe and some
  implementations may use global state, so for portability the use of
  readdir in a multithreaded program should be controlled using a mutex.
</quote>

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/




More information about the libvir-list mailing list