[systemd-devel] sdbus_event loop state mark as volatile?

Lennart Poettering lennart at poettering.net
Thu Oct 31 11:35:46 UTC 2019


On Do, 05.09.19 10:46, Stephen Hemminger (stephen at networkplumber.org) wrote:

> The libsystemd bus event loop is:
>
>
>         while (e->state != SD_EVENT_FINISHED) {
>                 r = sd_event_run(e, (uint64_t) -1);
>
> But since e->state is changed by another thread it
> should be marked volatile to avoid compiler thinking
> the state doesn't get changed.

None of systemd's libraries are thread safe. They are written in a
threads-aware style though. This means you should only use a specific
context object from a single thread at a time, and need to do your own
locking around it if that single thread shall change all the
time. systemd doesn't keep global state generally, which means doing
your own locking around the sd_xyz objects should suffice and work
reasonably well.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list