[systemd-devel] [PATCH] udevd: fix synchronization with settle when handling inotify events

David Herrmann dh.herrmann at gmail.com
Fri Apr 17 04:07:57 PDT 2015


Hi

On Mon, Apr 13, 2015 at 4:49 PM, Daniel Drake <drake at endlessm.com> wrote:
> On Sat, Apr 11, 2015 at 5:13 AM, David Herrmann <dh.herrmann at gmail.com> wrote:
>> Nice catch!
>>
>> There's indeed a small race between handling inotify and queuing up
>> the change-event. We need to re-loop there. One day we should switch
>> to sd-event to avoid such bugs... I mean the symptom is inherent to
>> queuing up events while handling them. Meh!
>
> Thanks for reviewing this. Reading your comment, I wonder if there is
> a small bug in the solution here.
>
> Sometimes we may handle inotify events, but without generating change
> events. After my change, we will loop again, but there may be no
> events pending, in which case we will block on the 3 second timeout
> before completing the next loop iteration and replying to settle's
> ping message.

Not really. If a ctrl-message is pending, it will still be pending on
the next iteration, and thus immediately wake up the epoll_wait().
We're level-triggered here, not edge triggered! Hence, as long as we
didn't dispatch the ctrl-message, it's still pending and keep us
awake.

Thanks
David


More information about the systemd-devel mailing list