From owner-freebsd-questions Mon Feb 7 11:28: 8 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mercure.IRO.UMontreal.CA (mercure.IRO.UMontreal.CA [132.204.24.67]) by builder.freebsd.org (Postfix) with ESMTP id 8016A4074 for ; Mon, 7 Feb 2000 11:28:03 -0800 (PST) Received: from blc22.IRO.UMontreal.CA (IDENT:root@blc22.IRO.UMontreal.CA [132.204.21.36]) by mercure.IRO.UMontreal.CA (8.9.3/8.9.3) with ESMTP id OAA12771; Mon, 7 Feb 2000 14:28:40 -0500 Received: (from beaupran@localhost) by blc22.IRO.UMontreal.CA (8.9.3/8.9.3) id OAA03923; Mon, 7 Feb 2000 14:28:36 -0500 Full-Name: Antoine Beaupre X-Authentication-Warning: blc22.IRO.UMontreal.CA: beaupran set sender to beaupran@IRO.UMontreal.CA using -f From: Antoine Beaupre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14495.7396.191900.130045@blc22.IRO.UMontreal.CA> Date: Mon, 7 Feb 2000 14:28:36 -0500 (EST) To: Dan Nelson Cc: Alfred Perlstein , Freebsd Questions Mailing list Subject: Re: PThreads References: <14494.21789.847287.358066@anarcat.dyndns.org> <20000207101438.Y25520@fw.wintelcom.net> <20000207132244.A81581@dan.emsphone.com> X-Mailer: VM 6.75 under Emacs 20.3.1 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 [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