FW: [PATCH] Stop packet_recv greediness, stop using event_add_timed

Sam Liddicott sam at liddicott.com
Tue May 19 06:06:06 GMT 2009

The ordering isn't purely dependant on eventlib.

Currently the ordering is
1. Expire timers (and 0 timers)
2. Socket fd, client decides if read or write takes priority.
3. Timers that timed out while waiting for (2) are picked up as (1) next time around.

It's not even really a timed event, it just uses timed events to implement. In the ordering it needs to be implemented at the same priority as socket reads - which for server sockets is after socket writes, and for client sockets is before socket writes. So packet_recv or tevent can't know how to prioritize it, only the socket owner knows.

Consider that I didn't address the DOS scenario Volker raised on IRC, so perhaps if instead of trying to leave one byte, what if I try to read only the correct number of bytes? This means reading a very few bytes until the socket owner can work out how many should be read.

Of course such a patch would be almost identical, but this time it would follow a less obnoxious strategy and also avoid DOS.

What do you think?



-----Original Message-----
From: Andrew Bartlett <abartlet at samba.org>
Sent: 18 May 2009 22:51
To: Sam Liddicott <sam at liddicott.com>
Cc: samba tech <samba-technical at lists.samba.org>; Volker Lendecke <Volker.Lendecke at SerNet.DE>
Subject: Re: FW: [PATCH] Stop packet_recv greediness, stop using event_add_timed

On Mon, 2009-05-18 at 17:32 +0100, Sam Liddicott wrote:
> Volker; hows this for style and intrusiveness?
> (It still needs modifying to avoid reading most of the queued bytes in 
> cases where the packet size isn't known).
> I don't yet have the data on how it affects throughput, but it does have 
> the effect of letting a server send out it's responses ASAP rather than 
> wait until all requests have been processed.
> Further work needs doing on fairness between different sockets, but that 
> will follow later, as Tom and I (mostly Tom) are still looking at those 
> cases.

Urgh.  I would really like to avoid 'one byte left on the socket' games.
The GnuTLS library tried to play those games, and we lost out badly when
something subtle broke it.  I would prefer a way to indicate to the
event lib that it should do this timed event at the end of the queue, if
that's what we actually need (otherwise, it all breaks if the event lib
changes it's ordering). 

Andrew Bartlett

Andrew Bartlett
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Red Hat Inc.

More information about the samba-technical mailing list