]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-event: refuse running default event loops in any other thread than the one they...
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Oct 2019 19:26:50 +0000 (20:26 +0100)
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>
Wed, 10 Mar 2021 11:41:30 +0000 (12:41 +0100)
(cherry picked from commit e544601536ac13a288d7476f4400c7b0f22b7ea1)

Related: #1819868

TODO
src/libsystemd/sd-event/sd-event.c

diff --git a/TODO b/TODO
index 8f7800008937a9fbb682808b89c201b829732839..3100e067d6f67e3481b91fad5723bf4b777472db 100644 (file)
--- a/TODO
+++ b/TODO
@@ -581,7 +581,6 @@ Features:
   - allow multiple signal handlers per signal?
   - document chaining of signal handler for SIGCHLD and child handlers
   - define more intervals where we will shift wakeup intervals around in, 1h, 6h, 24h, ...
-  - generate a failure of a default event loop is executed out-of-thread
   - maybe add support for inotify events (which we can do safely now, with O_PATH)
 
 * investigate endianness issues of UUID vs. GUID
index 88641879cc6ef133f03fb242de6aa229fc77a492..537a0b81d4cff2b61853d9b27e5d067ccd63b227 100644 (file)
@@ -3360,6 +3360,11 @@ _public_ int sd_event_prepare(sd_event *e) {
         assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
         assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
 
+        /* Let's check that if we are a default event loop we are executed in the correct thread. We only do
+         * this check here once, since gettid() is typically not cached, and thus want to minimize
+         * syscalls */
+        assert_return(!e->default_event_ptr || e->tid == gettid(), -EREMOTEIO);
+
         if (e->exit_requested)
                 goto pending;