BugTraq
readdir_r considered harmful Nov 01 2005 03:57AM
Ben Hutchings (ben decadentplace org uk) (2 replies)
Re: readdir_r considered harmful Nov 05 2005 06:45PM
Casper Dik Sun COM (1 replies)
Re: [Full-disclosure] Re: readdir_r considered harmful Nov 06 2005 01:53AM
Ulrich Drepper (drepper gmail com) (1 replies)
Re: [Full-disclosure] Re: readdir_r considered harmful Nov 06 2005 09:00AM
Casper Dik Sun COM (1 replies)
Re: [Full-disclosure] Re: readdir_r considered harmful Nov 06 2005 03:34PM
Ulrich Drepper (drepper gmail com) (1 replies)
Re: [Full-disclosure] Re: readdir_r considered harmful Nov 06 2005 07:19PM
Casper Dik Sun COM (1 replies)
Re: [Full-disclosure] Re: readdir_r considered harmful Nov 08 2005 01:47AM
Andrew Miller (andrew amxl com)
Casper.Dik (at) Sun (dot) COM [email concealed] wrote:
...

>Had they done so, we would never have had to use readdir_r() and progammers
>would not have introduced bugs in the (mis)use of pathconf, over allocating,
>etc.
>
>I would be interested in seeing any real-world use of readdir_r() in
>a context where readdir_r() is required (multiple threads reading from
>a single DIR *).
>
>
Consider the following situation(I'm not sure if anyone actually does this):
1) You have a "spool" directory containing a large number of files, each
which represents a task to process.
2) You have a number of worker threads. Each worker thread reads a file
from the global DIR*, and then opens and reads the file for
processing(and then loops on 2).

Of course, you could always just put a mutex around every call to
readdir(), and copy the filename somewhere safe, or you could invent a
signalling system to ask one thread to do all the readdir()s. Whether
this makes sense depends on how much of readdir_r has to be spent inside
a global mutex/spinlock anyway, and how long the processing part takes
compared with the readdir() part.

Andrew

[ reply ]
Re: readdir_r considered harmful Nov 01 2005 08:16PM
Ben Hutchings (ben decadentplace org uk)


 

Privacy Statement
Copyright 2010, SecurityFocus