Ugh, I should have brought this up before the code freeze but...
Maybe we could make 4.0 the transition point for adding locking
structures to FILE and DIR structures instead of the hackish
way it's done now (maintaining a seperate structure).
Does anyone agree or have time for this?
It would greatly simplify the code and actually fix the readdir_r
problem.
-Alfred
----- Forwarded message from "Richard Seaman, Jr." <[EMAIL PROTECTED]> -----
Date: Mon, 29 Nov 1999 15:32:50 -0600
From: "Richard Seaman, Jr." <[EMAIL PROTECTED]>
To: Alfred Perlstein <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: readdir_r thread safe?
Message-ID: <[EMAIL PROTECTED]>
X-Mailer: Mutt 1.0pre3i
On Mon, Nov 29, 1999 at 01:45:14PM -0800, Alfred Perlstein wrote:
> > I think the argument is more like what happens with the stream
> > functions fread(), fwrite(), etc. There are the flockfile() and
> > funlockfile() functions that are used within libc and libc_r to
> > lock the FILE structure. Locking the file descriptor element of
> > the FILE structure is not sufficient. Moreover, its not the
> > programmmer's responsibility to lock the FILE structure before
> > accessing the stream functions. libc does it for you. I think
> > this is what it means to be "thread safe".
>
> Ok, that makes sense.
>
> > Now, if you don't want readdir_r() to be "thread safe", and document
> > it as such, that's another matter.
>
> That's not my intention, I'll see what I can do to fix this.
And now.... you're about to open a "can of worms". :)
The simplest way, by far, to have implemented flockfile() and
funlockfile() would have been to add an element to the FILE
structure to hold the lock. The simplest way, by far, to lock
the DIR structure is to modify the DIR structure to hold a lock
element. Ditto for any other libc shareable structures, if there
are any.
But, I think this breaks compability, and would require a version
bump for libc. I think this is why John Birrell implemented
flockfile() etc. in the very convoluted way he did (it was the
only other choice).
I don't know what every one thinks about a version bump for libc,
but I think there are enough thread related changes that libc
requires that it should happen. But, probably someone needs to
wade through libc and find *all* the changes that are needed,
so that if the version bump is agreed to, it only happens once.
I started work on this about 9 months ago, got waylaid, and never
finished.
The alternative "hack" for the DIR structure that might work is
to lock the dd_fd every time you access the DIR structure, even
if you're not doing a file access. This might be equivalent to
locking the DIR structure, but I haven't investigated it fully.
--
Richard Seaman, Jr. email: [EMAIL PROTECTED]
5182 N. Maple Lane phone: 262-367-5450
Chenequa WI 53058 fax: 262-367-5852
----- End forwarded message -----
--
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message