Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Feb 2000 14:28:36 -0500 (EST)
From:      Antoine Beaupre <beaupran@IRO.UMontreal.CA>
To:        Dan Nelson <dnelson@emsphone.com>
Cc:        Alfred Perlstein <bright@wintelcom.net>, Freebsd Questions Mailing list <freebsd-questions@FreeBSD.ORG>
Subject:   Re: PThreads
Message-ID:  <14495.7396.191900.130045@blc22.IRO.UMontreal.CA>
References:  <14494.21789.847287.358066@anarcat.dyndns.org> <20000207101438.Y25520@fw.wintelcom.net> <20000207132244.A81581@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Eh-eh... The program has to be linux-compatible and I don't think
there's such a call in Linux (RH, at least) libs...

In fact, what I have done is that I simply pass the entry->d_name as
an argument and then lock it with a mutex. Then I do a strdup, in the
child thread.

Even if I strdup it, I end up with the same race problem on the new
string instead of the 'd_name'... (no?)

Does that makes sense?

Thanks.

--- Big Brother told Dan Nelson to write, at 13:22 of February 7:
> In the last episode (Feb 07), Alfred Perlstein said:
> > * Spidey <beaupran@iro.umontreal.ca> [000206 21:43] wrote:
> > > Hi!
> > > 
> > > I am currently working on a program that needs pthreads.
> > > 
> > > Is there some bugs in FBSD implementation of the pthreads? Because
> > > I'm having serious problems here:
> > 
> > yes, you can't possibly expect readdir() which returns a pointer to a
> > _static_ structure to be thread safe the way you are using it.
> > 
> > if you wanted to fix this, then I would strdup() the d_name in the
> > main thread then pass it to the slave threads, (don't forget to
> > free() it!)
> 
> You could also change your program to use readdir_r(), which is thread
> safe.
> 
> -- 
> 	Dan Nelson
> 	dnelson@emsphone.com

-- 
Si l'image donne l'illusion de savoir
C'est que l'adage pretend que pour croire,
L'important ne serait que de voir

Lofofora


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14495.7396.191900.130045>