[PATCH] readdir, readdir64 are thread-safe
Zack Weinberg
zackw@panix.com
Tue Apr 11 13:16:00 GMT 2017
On Tue, Apr 11, 2017 at 7:36 AM, Florian Weimer <fweimer@redhat.com> wrote:
> They only modify the state in the dirstream argument, and we
> generally do not treat this as a reason to mark a function as
> not thread-safe. For an example, see random_r, which is marked
> as thread-safe even though the random state is not protected
> by a lock.
Hmm. There's two issues here: first, POSIX specifically allows
readdir to be not thread-safe (although it's unclear to me what that
actually means) so it might be appropriate to keep the annotation
around to warn people that there is a portability concern; second, if
you share a DIR object among threads, a call to readdir in one thread
will clobber the previous return value, which might still be live in
another thread. Is that sufficient reason to call the *function*
thread-unsafe? We don't have any good place to warn people about that
*other* than the documentation for readdir. (Note that the text of
the @deftypefun does a very bad job of explaining what the problem
is.)
zw
More information about the Libc-alpha
mailing list