$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Giovanni P. Deretta (gpderetta_at_[hidden])
Date: 2006-02-08 11:28:15
Felipe Magno de Almeida wrote:
> On 2/7/06, Giovanni Piero Deretta <gpderetta_at_[hidden]> wrote:
> 
>>On 2/7/06, Giovanni P. Deretta <gpderetta_at_[hidden]> wrote:
>>
>>>
>>>Ah, btw, at least on posix systems, file descriptors are guaranteed to
>>>be allocated contiguously. So you could create a vector as big as the
>>>hightest fd, store the list of operations in it and use the socket_impl
>>>as a key for an O(1) lookup in the vector.
>>
>> This is not true of course... I don't know what i was thinking...
>>Anyway, a file descriptor is *usually* a small integer, so on those systems
>>that keep the set mostly contiguous a vector would work and not waste much
>>space.
> 
> 
> Why is not true? I think you were right. Although *all* file
> descriptors are contiguously, which means that other parts of the
> program may create "holes" in the vector. But it would work alright (I
> think ACE does this on Posix systems).
> 
After writing the first email I went and checket the SUSv3. No where it 
says that when the OS generates a new filedesc it needs to reuse the 
first number available.  In pratice i think that most posix systems do 
(there are many programs that rely on the set being small, think 
select() ). But consider dup2(), the user may duplicate a socket fd of 
value 4 with an fd of value 1234567 or whatever. Yes, this is evil, but 
might actually happen.
-- Giovanni P. Deretta