1
0
mirror of https://github.com/systemd/systemd synced 2026-04-23 15:34:50 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Yu Watanabe
f777e745a7 udev: do not call sd_event_source_disable_unref() in workers for event sources created by the main process
Fixes a bug introduced by 9612da361a825d70a9fd392f3ee5a53bf8896887.
2022-03-29 10:29:44 +02:00
Yu Watanabe
8166950763 inotify-util: fix wrong warnings in FOREACH_INOTIFY_EVENT()
Follow-up for 00adc340bb15bc9d634db6caa48f1c964b99f79a.

This fixes the wrong "Received invalid inotify event, ignoring." warnings
caused by the missing curly brackets and the priorities of `&&` and `?:`.

This also replaces the ternary operators with `||`.
2022-03-29 13:20:16 +09:00
2 changed files with 8 additions and 9 deletions

View File

@ -12,15 +12,12 @@
#define _FOREACH_INOTIFY_EVENT(e, buffer, sz, log_level, start, end) \
for (struct inotify_event \
*start = &((buffer).ev), \
*start = &((buffer).ev), \
*end = (struct inotify_event*) ((uint8_t*) start + (sz)), \
*e = start; \
(uint8_t*) e + sizeof(struct inotify_event) <= (uint8_t*) end && \
(uint8_t*) e + sizeof(struct inotify_event) + e->len <= (uint8_t*) end ? true : \
({ \
log_full(log_level, "Received invalid inotify event, ignoring."); \
false; \
}); \
(size_t) ((uint8_t*) end - (uint8_t*) e) >= sizeof(struct inotify_event) && \
((size_t) ((uint8_t*) end - (uint8_t*) e) >= sizeof(struct inotify_event) + e->len || \
(log_full(log_level, "Received invalid inotify event, ignoring."), false)); \
e = (struct inotify_event*) ((uint8_t*) e + sizeof(struct inotify_event) + e->len))
#define _FOREACH_INOTIFY_EVENT_FULL(e, buffer, sz, log_level) \

View File

@ -210,8 +210,10 @@ DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(worker_hash_op, void, trivial_hash
static void manager_clear_for_worker(Manager *manager) {
assert(manager);
manager->inotify_event = sd_event_source_disable_unref(manager->inotify_event);
manager->kill_workers_event = sd_event_source_disable_unref(manager->kill_workers_event);
/* Do not use sd_event_source_disable_unref() here, as this is called by both workers and the
* main process. */
manager->inotify_event = sd_event_source_unref(manager->inotify_event);
manager->kill_workers_event = sd_event_source_unref(manager->kill_workers_event);
manager->event = sd_event_unref(manager->event);