[PATCH] event-loop: Only read one epoll event per loop dispatch.

Jonas Ådahl jadahl at gmail.com
Mon Mar 19 11:57:58 PDT 2012

On Mon, Mar 19, 2012 at 7:10 PM, Bill Spitzak <spitzak at gmail.com> wrote:
> Jonas Ådahl wrote:
>> That would not work because ep[i].data.ptr will already be loaded with
>> the source pointer pointing to deallocated memory. It doesn't matter
>> if that particular source is free:ed and removed from the epoll state
>> since it has already been triggered to dispatch. Another approach
>> would be to flag an event source for removal if it already has been
>> queued up then have the event_loop_dispatch function remove it after
>> or instead of handling it.
> How about having the data point at another object that points at the source.
> This object is not deleted until after the epoll is used, but when the
> source is deleted it is set to zero so this is detectable.

An event source container acting as a proxy between epoll and the
event source? When receiving an event, instead of marking the event
source directly, one could mark the container as queued. When an event
source is removed from epoll then one can check if it has been queued
by accessing the container via the event source, and in that case mark
it for destruction, or free it directly in case it wasn't. Is this
what you mean? It sounds quite reasonable.


More information about the wayland-devel mailing list