Kashyap Ashwin wrote:
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.

Ah. Interesting. This is exactly opposite what I wanted when I wrote this code.


This code was originally written for use in the Event MPM, where a single pollset might have thousands of sockets with no harm.

The primary design motivation was allowing multiple threads to safely and quickly call _add() without blocking.

If _add() could fail because the pollset was too small, different threads would need to force synchronization and create a new larger pollset. This would cause the server to hiccup while creating a new pollset, and a separate Pool to operate without unbounded memory growth.

This led to my decision to use a linked list that recycles the removed pollfds. This allows any thread to quickly call _add() without having to worry about the pollset size, and allows the pollset to reuse its memory.

-Paul

Reply via email to