Re: file ID redesign proposal

Dean Gaudet (dgaudet-list-linux-kernel@arctic.org)
Wed, 26 Nov 1997 09:47:57 -0800 (PST)


On Wed, 26 Nov 1997, Ingo Molnar wrote:

> On Tue, 25 Nov 1997, Dean Gaudet wrote:
>
> > Please keep fcntl(F_DUPFD) in mind ... [...]
>
...
> NOTE: the only problem i see with this scheme (so far), are we required to
> guarantee first-free-file-ID-allocation of file IDs?

Yep. Without it F_DUPFD is useless for what Apache uses it for. We
maintain two "spaces" of filedescriptors, one above LOW_SLACK_LINE, the
other below. If open()/socket()/etc allocate above the LOW_SLACK_LINE
when there are still free descriptors below it then there's no point in
using F_DUPFD in the first place. This breaks Apache when linked with
various libraries (which have embedded fd_set functions...).

Isn't it possible to get away with close() being the only O(lg(n))
operation? Suppose close() maintains an ordered list, through whatever
method. You can arrange it so that allocation is O(1). You don't need to
build the list initially, keep a high_water_mark which indicates the
highest fd allocated so far. If the free list is empty, then just use
high_water_mark.

Oh I suppose that makes F_DUPFD O(lg(n)) as well, but that doesn't bother
me much ...

Dean