chiark / gitweb /
sd-event: "when exiting no signal event are pending" is a wrong assertion (#5271)
authorFranck Bui <fbui@suse.com>
Wed, 8 Feb 2017 19:56:22 +0000 (20:56 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 19 Jun 2017 07:40:51 +0000 (09:40 +0200)
commitd22c4385791244b245652a6ddaeed4f20d3d1137
treee1b7d75ba59dc91c6f2bc607438447ccb54d9188
parentdad879d0bdf2b21c47fe11d1464a2da2e3ec6b8b
sd-event: "when exiting no signal event are pending" is a wrong assertion (#5271)

The code make the following assertion: when freeing a event loop object
(usually it's done after exiting from the main event loop), no signal events
are still queued and are pending.

This assertion can be found in event_unmask_signal_data() with
"assert(!d->current);" assertion.

It appears that this assertion can be wrong at least in a specific case
described below.

Consider the following example which is inspired from udev: a process defines 3
source events: 2 are created by sd_event_add_signal() and 1 is created by
sd_event_add_post().

 1. the process receives the 2 signals consecutively so that signal 'A' source
     event is queued and pending. Consequently the post source event is also
     queued and pending. This is done by sd_event_wait().

 2. The callback for signal 'A' is called by sd_event_dispatch().

 3. The next call to sd_event_wait() will queue signal 'B' source event.

 4. The callback for the post source event is called and calls sd_event_exit().

 5. the event loop is exited.

 6. freeing the event loop object will lead to the assertion failure in
     event_unmask_signal_data().

This patch simply removes this assertion as it doesn't seem to be a
bug if the signal data still reference a signal source at this point.

(cherry picked from commit 4470860388e12a5dda1d65773e411a349221a3e9)
src/libelogind/sd-event/sd-event.c