Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-21 Thread Roland Dreier
+buf = alloca(offsetof(struct dirent, d_name) + NAME_MAX + 1); +while (readdir_r(class_dir, buf, dent) == 0 dent) { So after thinking this over, I don't think I'm going to apply this patch. I think the right fix is for corosync to allow readdir() -- in general pushing people to

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-08 Thread Jason Gunthorpe
On Thu, Jul 08, 2010 at 11:27:48AM -0700, Roland Dreier wrote: I'm really not sure about this patch one way or another. With alloca, it ends up looking pretty clean, but we do introduce the tiny possibility of buffer overrun (since readdir_r uses a user-supplied buffer of poorly-specified

[PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
From: Steven Dake sd...@cast.broked.org The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been tested with a libibverbs application (http://www.corosync.org) on Mellanox MT26428 cards. Signed-off-by: Steven

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Jason Gunthorpe
On Wed, Jul 07, 2010 at 11:37:01AM -0700, Steven Dake wrote: From: Steven Dake sd...@cast.broked.org The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been tested with a libibverbs application

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Roland Dreier
The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been tested with a libibverbs application (http://www.corosync.org) on Mellanox MT26428 cards. This is a bit vague. Is the problem that other threads

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
On 07/07/2010 11:52 AM, Jason Gunthorpe wrote: On Wed, Jul 07, 2010 at 11:37:01AM -0700, Steven Dake wrote: From: Steven Dakesd...@cast.broked.org The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
On 07/07/2010 11:54 AM, Roland Dreier wrote: The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been tested with a libibverbs application (http://www.corosync.org) on Mellanox MT26428 cards.

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Jason Gunthorpe
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

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
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

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Jason Gunthorpe
On Wed, Jul 07, 2010 at 02:24:45PM -0700, Steven Dake wrote: 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. Override opendir and allocate the

[PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
From: Steven Dake sd...@cast.broked.org The readdir POSIX api is not thread safe. This presents problems in multithreaded programs that use the libibverbs APIs. This patch has been tested with a libibverbs application (http://www.corosync.org) on Mellanox MT26428 cards. This updated version

Re: [PATCH] change thread-unsafe readdir to thread-safe readdir_r calls

2010-07-07 Thread Steven Dake
On 07/07/2010 02:49 PM, Jason Gunthorpe wrote: On Wed, Jul 07, 2010 at 02:24:45PM -0700, Steven Dake wrote: 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