apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kashyap Ashwin" <Ashwin.Kash...@thomson.net>
Subject RE: epoll.c bug
Date Mon, 24 Jan 2005 22:48:51 GMT
Hello Paul,
Well, I wanted to limit the queue length of accepted connections (limit
pollset ring length), and I was relying on pollset_add() returning me
some error if I try to add a pollfd beyond the allocated size. Looks
like I have to do this myself.


-----Original Message-----
From: Paul Querna [mailto:chip@force-elite.com] 
Sent: Monday, January 24, 2005 4:09 PM
To: Kashyap Ashwin
Cc: dev@apr.apache.org
Subject: Re: epoll.c bug

Hash: SHA1

Kashyap Ashwin wrote:
| Hi,
| I noticed that pollset->nalloc is not checked in pollset_add in
| 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
| 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