On 07/07/2010 01:47 PM, Jason Gunthorpe wrote:
On Wed, Jul 07, 2010 at 12:14:16PM -0700, Steven Dake wrote:

But, you surely could not have seen a bug on Linux that was caused by
this - so why was this patch prepared?

We redefine all the non-thread-safe posix calls in our package (such as
readdir) to assert(0).  This prevents their usage in our app.  The
reason we do this is to prevent plugin developers from writing plugins
that use non-thread-safe posix APIs.  Our app is portable, where the
glibc semantics you describe above are not present.  POSIX is blank on
this issue, and was addressed in readdir_r.

Well, if you are already creating wrappers, wouldn't it be better to
provide wrappers that provide the glibc functionality on platforms you
port to that don't already do that, rather than forbid a perfectly
functional, and thread safe, call?


Not sure how to map a readdir to readdir_r on a thread unsafe system... perhaps with thread keys. In any regard, seems pointless, readdir_r is there and what POSIX specifies for this purpose.

FWIW, I've always considered readdir_r to be broken, you pass in a
buffer without passing in a size and hope everything works out. Your

I also have objections to some POSIX standard APIs - however, using non-reentrant POSIX apis when reentrant POSIX APIs are available seems counterproductive.

proposed patch to libibverbs is also not-portable because it uses
NAME_MAX, not pathconf.. Sigh POSIX.


On bsd/solaris/darwin/linux, NAME_MAX is defined. Not sure which other POSIX systems one would care about..

I guess, as a general question, do you know of any libc
implementations that actually use a static buffer for readdir and
would require readdir_r to function properly?

I have not looked at each libc's implementation to see if it matches the glibc behaviour. The resolution provided by glibc seems like an enhancement over POSIX, where the behaviour is unspecified.

Regards
-steve

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to