[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cancel read on socket



Ralf Corsepius wrote:
> On Wed, 2008-05-28 at 09:22 +0300, Leon Pollak wrote:
>> On Wednesday, 28 ?May 2008, Chris Johns wrote:
>>> Joel Sherrill wrote:
>>>> Without thinking about compatibility at all, shouldn't it be
>>>> possible to add an RTEMS specific IOCTL which forced
>>>> a read() to return an error like ECANCELED?
>>> I do not think this is a good idea. Other ways to solve this problem have
>>> been suggested.
> I agree with Chris.
> 
>> As someone who feels strong interest in this, can I ask the question - why is 
>> this not a good idea?
> It is very error prone and difficult to implement.

Agreed.

> 
> Think along these lines from POSIX:
> ...
> If a read() is interrupted by a signal before it reads any data, it
> shall return -1 with errno set to [EINTR].
> 
> If a read() is interrupted by a signal after it has successfully read
> some data, it shall return the number of bytes read.
> ...
> 
> How would you handle canceling io?
> 

Yes a good question. Having played with a patch for a safe close of sockets 
there is a range of issues to consider inside the stack.

> 
> In addition to that, I am opposed to adding anything proprietary to a
> standardized API.
> 

I agree and also ask the question, if such a call was needed surely it would 
have been added to the standards. Maybe developers of the APIs and the 
standards creators know other solutions exist.

Regards
Chris