Ghennadi Procopciuc | 25 Jul 2012 10:29
Favicon

[Patch] Fix reading from a tcp socket

Hi all,

We discovered a bug that occurs in two situations :

1.When many responses come simultaneously, c-ares reads only the first; after that,
   it awaits another notification for each of them. However,  until a read does not return EAGAIN

   epoll does not send notifications for that socket anymore.

2.A big DNS message is divided in several IP packets, c-ares is expected to read
   the full message or to receive EAGAIN. This works appropriately for UDP but not TCP.

I attached a patch that fixes these issues.

Thanks,
Ghennadi

Attachment (0001-Fix-reading-from-a-tcp-socket.patch): application/octet-stream, 1624 bytes
Ben Greear | 25 Jul 2012 17:27
Favicon

Re: [Patch] Fix reading from a tcp socket

On 07/25/2012 01:29 AM, Ghennadi Procopciuc wrote:
> Hi all,
>
> We discovered a bug that occurs in two situations :
>
> 1.When many responses come simultaneously, c-ares reads only the first; after that,
>     it awaits another notification for each of them. However,  until a read does not return EAGAIN
>
>     epoll does not send notifications for that socket anymore.
>
> 2.A big DNS message is divided in several IP packets, c-ares is expected to read
>     the full message or to receive EAGAIN. This works appropriately for UDP but not TCP.
>
> I attached a patch that fixes these issues.

Maybe using a while loop would be a little more intuitive?

Thanks,
Ben

>
> Thanks,
> Ghennadi
>

--

-- 
Ben Greear <greearb@...>
Candela Technologies Inc  http://www.candelatech.com

Daniel Stenberg | 25 Jul 2012 23:10
Picon
Favicon
Gravatar

Re: [Patch] Fix reading from a tcp socket

On Wed, 25 Jul 2012, Ben Greear wrote:

> Maybe using a while loop would be a little more intuitive?

Yes please, make it into a "normal" loop instead!

--

-- 

  / daniel.haxx.se

Ghennadi Procopciuc | 9 Aug 2012 15:09
Favicon

RE: [Patch] Fix reading from a tcp socket

Version 2

Thanks,
Ghennadi
Attachment (0001-Fix-reading-from-a-tcp-socket.patch): application/octet-stream, 4313 bytes
Ghennadi Procopciuc | 21 Aug 2012 09:10
Favicon

RE: [Patch] Fix reading from a tcp socket

Any feedback on this version ?

Thanks,
Ghennadi

William Ahern | 25 Jul 2012 21:53

Re: [Patch] Fix reading from a tcp socket

On Wed, Jul 25, 2012 at 08:29:12AM +0000, Ghennadi Procopciuc wrote:
> Hi all,
> 
> We discovered a bug that occurs in two situations :
> 
> 1.When many responses come simultaneously, c-ares reads only the first; after that,
>    it awaits another notification for each of them. However,  until a read
>    does not return EAGAIN epoll does not send notifications for that
>    socket anymore.

That should only happen if you're using edge-triggered mode for the event.
By default epoll should be using level-triggered mode.


Gmane