Nice work! Re: EXPERIMENTAL: tevent_kqueue support

Stefan (metze) Metzmacher metze at samba.org
Wed Mar 6 13:11:37 MST 2013


Am 06.03.2013 21:04, schrieb Jeremy Allison:
> On Wed, Mar 06, 2013 at 03:02:32PM -0500, Simo wrote:
>> On 03/06/2013 02:57 PM, Jeremy Allison wrote:
>>> On Wed, Mar 06, 2013 at 10:47:05AM -0500, Ira Cooper wrote:
>>>
>>>> On Wed, Mar 6, 2013 at 10:18 AM, Stefan (metze) Metzmacher <metze at samba.org>
>>>>
>>>>      Solaris/illumos has /dev/poll, correct?
>>>>      I haven't looked into details, but that should provide the same
>>>>      features
>>>>      as poll(),
>>>>      which means the kernel reports POLLIN and POLLOUT together.
>>>>
>>>> In re-reading the doc, for port_associate, I think you are right.  It'll do
>>>> that.  But it will only give 1 event per fd.
>>>>
>>>> http://docs.oracle.com/cd/E23824_01/html/821-1465/port-associate-
>>>> 3c.html#scrolltoc
>>> We should be able to build a tevent backend on top of port_create()/
>>> port_associate()/port_getn() and friends.
>>>
>>> The only tricky bit I see is re-adding the fd events that have
>>> fired back (as port_getn() "helpfully" removes them once they've
>>> triggered :-).
>>>
>>> Same for kqueue I think.
>>
>> Shouldn't be too difficult you just need an inner wrapping for
>> tevent_fd_add and friends so that the callbacks goes first through
>> an internal callback that readds the fd once the event has been
>> dealt with by the 'real' callback and unless it has been modified by
>> the callback of course.
>>
>> event fires
>>   \-> internal callback
>>       | \-> real callback
>>       \--re-add event

Using port_create()/port_associate()/port_getn() should be easy.

We should do it like

 event fires
   \-> internal callback
       \-> re-add event
       \-> real callback

as the real callback can alter the event.

> Yep. The reason I think adding both these systems is possible
> for tevent is :
> 
> git clone https://github.com/libevent/libevent.git
> 
> which already has both systems plumbed in :-). Learn from
> the best as I always say :-).

kqueue is almost done
https://gitweb.samba.org/?p=metze/samba/wip.git;a=commitdiff;h=5eb9cc551d9e488daef34ace132a6d7b2e43152c
as said before it behaves differently than all other backends
and never give TEVENT_FD_READ and TEVENT_FD_WRITE at the same time
even if there's one byte in the recv queue no bytes in the send queue.

And during a make test on freebsd 9 it triggered more failures
than the poll backend...

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20130306/432972f6/attachment.pgp>


More information about the samba-technical mailing list