[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-16 Thread Rock Li
Rock Li added the comment: You are right. I checked the GLibc implementation of readdir and readdir_r, there's no global variale used in the function readdir. Just as the POSIX standards says, "This data is not overwritten by another call to readdir() on a different directory stream". To the

[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Ross Lagerwall
Ross Lagerwall added the comment: That text was from the POSIX 2008 spec: http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html The following text from my copy of the readdir manpage gives an indication of how you *should* allocate struct dirent when using readdir_r: """ Since

[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread R. David Murray
R. David Murray added the comment: My man page says "The data returned by readdir() may be overwritten by subsequent calls to readdir() for the same directory stream." Ross I believe was quoting from the posix *spec*, so that is a more complete explanation. If an implementation is doing wh

[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Rock Li
Rock Li added the comment: Hi Ross, What about if one implementation of posix use the global variable to store something. From `man readdir`, I didn't see the sentence "This data is not overwritten by another call to readdir() on a different directory stream.". And from the link you gived,

[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Ross Lagerwall
Ross Lagerwall added the comment: Hi, There shouldn't be a problem with the existing implementation since, according to posix: """ The pointer returned by readdir() points to data which may be overwritten by another call to readdir() on the same directory stream. This data is not overwritten

[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Rock Li
New submission from Rock Li: When I'm how glob module is implemented. I found in file posixmodule.c, the function posix_listdir is using readdir to get all the entries under one directory and the context is setted to allow multi threads. But the function readdir is not thread-safe, so I change