apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Querna <c...@force-elite.com>
Subject Re: epoll.c bug
Date Mon, 24 Jan 2005 21:09:20 GMT
Hash: SHA1

Kashyap Ashwin wrote:
| Hi,
| I noticed that pollset->nalloc is not checked in pollset_add in epoll.c.
| select.c has:
|     if (pollset->nelts == pollset->nalloc) {
|         return APR_ENOMEM;
|     }
| Shouldn't epoll.c also have this check?

No. epoll is expandable beyond the initial nalloc. (it stores all of its
pollfds in a linked list).  nalloc only effects the maximum number of
events that will be returned by a single _poll call.

| Also, you are incrementing nelts for every pollset_add, but never
| decrementing it. This will eventually cause an overflow. It will also
| make the above fix to epoll.c broken.

While this in some ways is a bug, nelts is not used for any part of the
epoll implementation, and could be safely removed. This is just a left
over variable from the original poll version that I didn't remove. (an
overflow will not even hurt it).

| This is really causing me trouble, I am trying to implement something
| like SEDA (staged event driven execution) where I have to add and remove
| pollfd from a pollset a few thousand times, whenever there is some

It might be interesting to add a _enable and _disable set of functions
to the API, since KQueue supports turning off a FD for events, but not
removing it.

- -Paul Querna
Version: GnuPG v1.2.4 (Darwin)


View raw message