-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 8/31/2009 5:38 PM: > Notice that this changes the status of fdopendir - whereas it was previously > non-multithread safe and could call _exit, the mingw version of fdopendir is > now threadsafe and avoids _exit.
Well, not entirely threadsafe. There is a window between when rpl_open() does a stat() to learn that name is a directory, and when fchdir/fdopendir (via chdir()/opendir()) uses that name later on. It's not as pronounced on mingw, where you can't rename an in-use directory (and we could even open up a directory HANDLE to prevent users from changing it behind our backs), but it probably is asking for problems on Unix if another process is actively changing the same hierarchy as what we just tied to the fchdir metadata table. So on second thought, for systems with fchdir and which can open() directories without help, I'd rather stick with save_cwd/fchdir/opendir/restore_cwd rather than risk an optimized fdopendir that exposes the user to a multi-process data race. At least with the fchdir approach to fdopendir, you have limited your problems only to a race between threads in a single process, rather than something exploitable by other processes. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqceEYACgkQ84KuGfSFAYCkQACeJsHocH5U2USkxI9aP/HG2B8f kVoAoIPtnTxbHHFgX7RnX8VQuoEC+7sE =TAb9 -----END PGP SIGNATURE-----