loop wakeups and will not be dispatched, until they are enabled
again.</para>
- <para><function>sd_event_source_get_enabled()</function> may be
- used to query whether the event source object
- <parameter>source</parameter> is currently enabled or not. It
- returns the enablement state (one of <constant>SD_EVENT_ON</constant>,
- <constant>SD_EVENT_OFF</constant>, <constant>SD_EVENT_ONESHOT</constant>)
- in <parameter>enabled</parameter>, if it is not <constant>NULL</constant>.
- It also returns true if the event source is not disabled.</para>
+ <para><function>sd_event_source_get_enabled()</function> may be used to query whether the event source
+ object <parameter>source</parameter> is currently enabled or not. If both the
+ <parameter>source</parameter> and the output parameter <parameter>enabled</parameter> are
+ <constant>NULL</constant>, this function returns false. Otherwise, <parameter>source</parameter> must be
+ a valid pointer to an <structname>sd_event_source</structname> object. If the output parameter
+ <parameter>enabled</parameter> is not <constant>NULL</constant>, it is set to the enablement state (one
+ of <constant>SD_EVENT_ON</constant>, <constant>SD_EVENT_OFF</constant>,
+ <constant>SD_EVENT_ONESHOT</constant>). The function also returns true if the event source is not
+ disabled.</para>
<para>Event source objects are enabled when they are first created
with calls such as
}
#endif
- if (f->file->post_change_timer) {
- if (sd_event_source_get_enabled(f->file->post_change_timer, NULL) > 0)
- journal_file_post_change(f->file);
-
- sd_event_source_disable_unref(f->file->post_change_timer);
- }
+ if (sd_event_source_get_enabled(f->file->post_change_timer, NULL) > 0)
+ journal_file_post_change(f->file);
+ sd_event_source_disable_unref(f->file->post_change_timer);
managed_journal_file_set_offline(f, true);
return sd_event_source_set_enabled(s, SD_EVENT_OFF);
}
-int event_source_is_enabled(sd_event_source *s) {
- if (!s)
- return false;
-
- return sd_event_source_get_enabled(s, NULL);
-}
-
int event_add_time_change(sd_event *e, sd_event_source **ret, sd_event_io_handler_t callback, void *userdata) {
_cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
_cleanup_close_ int fd = -1;
const char *description,
bool force_reset);
int event_source_disable(sd_event_source *s);
-int event_source_is_enabled(sd_event_source *s);
int event_add_time_change(sd_event *e, sd_event_source **ret, sd_event_io_handler_t callback, void *userdata);
}
_public_ int sd_event_source_get_enabled(sd_event_source *s, int *ret) {
+ /* Quick mode: the event source doesn't exist and we only want to query boolean enablement state. */
+ if (!s && !ret)
+ return false;
+
assert_return(s, -EINVAL);
assert_return(!event_pid_changed(s->event), -ECHILD);
/* Not necessary to resolve the endpoint. */
return 0;
- if (event_source_is_enabled(peer->resolve_retry_event_source) > 0)
+ if (sd_event_source_get_enabled(peer->resolve_retry_event_source, NULL) > 0)
/* Timer event source is enabled. The endpoint will be resolved later. */
return 0;