You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Mladen Turk <mt...@apache.org> on 2006/06/27 13:25:45 UTC

apr_pollset, modifying reqevents

Hi,

I propose a new function apr_poll_modify, or
modifying apr_poll_add to be able to change
the interest ops/events for a designated apr_pollfd_t.

The point is to have an option to modify the
request events (poll options) without the need
to remove/add the same socket with different reqevents.

For example initially the socket might be
registered with APR_POLLIN, and then later after
the pollset_poll call it might be registered as
APR_POLLOUT without the need for remove/add.

It can be done two ways:

1. By using existing apr_pollset_add and depending
    if the apr_pollfd_t is already member of the
    pollset or not, execute real add or modify.
    This would allow possibility to be backported.

2. Adding a new function apr_pollset_modify.

I would prefer the first way, because it mean
'add' or 'add with different reqevents'.
The only drawback I can see is that it would
disallow to have a apr_pollfd_t added multiple
times to the pollset (BTW I think that we wish
to disable that anyhow by looking at the select.c
where we explicitly search for duplicate fd's on
remove).

Any comments?


Regards,
Mladen.



Re: apr_pollset, modifying reqevents

Posted by Paul Querna <ch...@force-elite.com>.
Mladen Turk wrote:
> Paul Querna wrote:
>> Mladen Turk wrote:
>>> Hi,
>>>
>>> I propose a new function apr_poll_modify, or
>>> modifying apr_poll_add to be able to change
>>> the interest ops/events for a designated apr_pollfd_t.
>>
>> And adding a modify to that API -- since it makes better assumptions
>> about the lifetimes of apr_pollfd_t's.  I don't think the _modify
>> paradigm will be easy to push onto the current apr_pollset API.
>>
> 
> I think its not that complicated:
> 
> found = 0
> for (...)
>    if descriptor part of pollset
>       found = 1
> 
> if  found
>   ret = epoll_ctl(pollset->epoll_fd, EPOLL_CTL_MOD,
>                   descriptor->desc.f->filedes, &ev);
> else
>   ret = epoll_ctl(pollset->epoll_fd, EPOLL_CTL_ADD,
>                   descriptor->desc.f->filedes, &ev);

Yeah, but this is an O(n) operation. Suck.

With apr_pollcb, it could be an O(1) operation.  Maybe its okay to add
it to apr_pollset, as long as we document how inefficient it is :)

-Paul

Re: apr_pollset, modifying reqevents

Posted by Mladen Turk <mt...@apache.org>.
Paul Querna wrote:
> Mladen Turk wrote:
>> Hi,
>>
>> I propose a new function apr_poll_modify, or
>> modifying apr_poll_add to be able to change
>> the interest ops/events for a designated apr_pollfd_t.
> 
> And adding a modify to that API -- since it makes better assumptions 
> about the lifetimes of apr_pollfd_t's.  I don't think the _modify 
> paradigm will be easy to push onto the current apr_pollset API.
>

I think its not that complicated:

found = 0
for (...)
    if descriptor part of pollset
       found = 1

if  found
   ret = epoll_ctl(pollset->epoll_fd, EPOLL_CTL_MOD,
                   descriptor->desc.f->filedes, &ev);
else
   ret = epoll_ctl(pollset->epoll_fd, EPOLL_CTL_ADD,
                   descriptor->desc.f->filedes, &ev);

Regards,
Mladen.

Re: apr_pollset, modifying reqevents

Posted by Paul Querna <ch...@force-elite.com>.
Mladen Turk wrote:
> Hi,
> 
> I propose a new function apr_poll_modify, or
> modifying apr_poll_add to be able to change
> the interest ops/events for a designated apr_pollfd_t.
> 
> The point is to have an option to modify the
> request events (poll options) without the need
> to remove/add the same socket with different reqevents.
> 
> For example initially the socket might be
> registered with APR_POLLIN, and then later after
> the pollset_poll call it might be registered as
> APR_POLLOUT without the need for remove/add.
> 
> It can be done two ways:
> 
> 1. By using existing apr_pollset_add and depending
>    if the apr_pollfd_t is already member of the
>    pollset or not, execute real add or modify.
>    This would allow possibility to be backported.
> 
> 2. Adding a new function apr_pollset_modify.
> 
> I would prefer the first way, because it mean
> 'add' or 'add with different reqevents'.
> The only drawback I can see is that it would
> disallow to have a apr_pollfd_t added multiple
> times to the pollset (BTW I think that we wish
> to disable that anyhow by looking at the select.c
> where we explicitly search for duplicate fd's on
> remove).

I believe we would be better off finishing the pollcb api:
http://svn.apache.org/repos/asf/apr/apr/branches/pollcb-dev/poll/unix/epoll.c

And adding a modify to that API -- since it makes better assumptions 
about the lifetimes of apr_pollfd_t's.  I don't think the _modify 
paradigm will be easy to push onto the current apr_pollset API.

-Paul