mirror of
https://github.com/systemd/systemd
synced 2024-07-09 04:26:06 +00:00
Merge pull request #33071 from keszybz/sd_event_source-cleanup
Clean up calls to sd_event_source_set_enabled()
This commit is contained in:
commit
a07c903a38
|
@ -734,9 +734,6 @@ static int automount_start_expire(Automount *a) {
|
|||
static void automount_stop_expire(Automount *a) {
|
||||
assert(a);
|
||||
|
||||
if (!a->expire_event_source)
|
||||
return;
|
||||
|
||||
(void) sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_OFF);
|
||||
}
|
||||
|
||||
|
|
|
@ -1738,9 +1738,6 @@ static void socket_unwatch_fds(Socket *s) {
|
|||
if (p->fd < 0)
|
||||
continue;
|
||||
|
||||
if (!p->event_source)
|
||||
continue;
|
||||
|
||||
r = sd_event_source_set_enabled(p->event_source, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_unit_debug_errno(UNIT(s), r, "Failed to disable event source: %m");
|
||||
|
|
|
@ -514,7 +514,6 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
|||
goto fail;
|
||||
}
|
||||
} else {
|
||||
|
||||
r = sd_event_add_time(
|
||||
UNIT(t)->manager->event,
|
||||
&t->monotonic_event_source,
|
||||
|
@ -529,8 +528,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
|||
(void) sd_event_source_set_description(t->monotonic_event_source, "timer-monotonic");
|
||||
}
|
||||
|
||||
} else if (t->monotonic_event_source) {
|
||||
|
||||
} else {
|
||||
r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_OFF);
|
||||
if (r < 0) {
|
||||
log_unit_warning_errno(UNIT(t), r, "Failed to disable monotonic event source: %m");
|
||||
|
|
|
@ -2983,16 +2983,8 @@ int unit_enqueue_rewatch_pids(Unit *u) {
|
|||
}
|
||||
|
||||
void unit_dequeue_rewatch_pids(Unit *u) {
|
||||
int r;
|
||||
assert(u);
|
||||
|
||||
if (!u->rewatch_pids_event_source)
|
||||
return;
|
||||
|
||||
r = sd_event_source_set_enabled(u->rewatch_pids_event_source, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to disable event source for tidying watched PIDs, ignoring: %m");
|
||||
|
||||
u->rewatch_pids_event_source = sd_event_source_disable_unref(u->rewatch_pids_event_source);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,10 +142,8 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
|
|||
}
|
||||
|
||||
if (timeout_ms < 0) {
|
||||
if (g->timer) {
|
||||
if (sd_event_source_set_enabled(g->timer, SD_EVENT_OFF) < 0)
|
||||
return -1;
|
||||
}
|
||||
if (sd_event_source_set_enabled(g->timer, SD_EVENT_OFF) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -784,12 +784,10 @@ static void server_sync(Server *s, bool wait) {
|
|||
"Failed to sync user journal, ignoring: %m");
|
||||
}
|
||||
|
||||
if (s->sync_event_source) {
|
||||
r = sd_event_source_set_enabled(s->sync_event_source, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
|
||||
"Failed to disable sync timer source: %m");
|
||||
}
|
||||
r = sd_event_source_set_enabled(s->sync_event_source, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
|
||||
"Failed to disable sync timer source, ignoring: %m");
|
||||
|
||||
s->sync_scheduled = false;
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ static thread_local sd_event *default_event = NULL;
|
|||
static void source_disconnect(sd_event_source *s);
|
||||
static void event_gc_inode_data(sd_event *e, struct inode_data *d);
|
||||
|
||||
static sd_event *event_resolve(sd_event *e) {
|
||||
static sd_event* event_resolve(sd_event *e) {
|
||||
return e == SD_EVENT_DEFAULT ? default_event : e;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ static void free_clock_data(struct clock_data *d) {
|
|||
prioq_free(d->latest);
|
||||
}
|
||||
|
||||
static sd_event *event_free(sd_event *e) {
|
||||
static sd_event* event_free(sd_event *e) {
|
||||
sd_event_source *s;
|
||||
|
||||
assert(e);
|
||||
|
@ -446,7 +446,7 @@ fail:
|
|||
}
|
||||
|
||||
/* Define manually so we can add the origin check */
|
||||
_public_ sd_event *sd_event_ref(sd_event *e) {
|
||||
_public_ sd_event* sd_event_ref(sd_event *e) {
|
||||
if (!e)
|
||||
return NULL;
|
||||
if (event_origin_changed(e))
|
||||
|
@ -474,8 +474,13 @@ _public_ sd_event* sd_event_unref(sd_event *e) {
|
|||
_unused_ _cleanup_(sd_event_unrefp) sd_event *_ref = sd_event_ref(e);
|
||||
|
||||
_public_ sd_event_source* sd_event_source_disable_unref(sd_event_source *s) {
|
||||
if (s)
|
||||
(void) sd_event_source_set_enabled(s, SD_EVENT_OFF);
|
||||
int r;
|
||||
|
||||
r = sd_event_source_set_enabled(s, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to disable event source %p (%s): %m",
|
||||
s, strna(s->description));
|
||||
|
||||
return sd_event_source_unref(s);
|
||||
}
|
||||
|
||||
|
@ -1178,7 +1183,7 @@ static int source_set_pending(sd_event_source *s, bool b) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType type) {
|
||||
static sd_event_source* source_new(sd_event *e, bool floating, EventSourceType type) {
|
||||
|
||||
/* Let's allocate exactly what we need. Note that the difference of the smallest event source
|
||||
* structure to the largest is 144 bytes on x86-64 at the time of writing, i.e. more than two cache
|
||||
|
@ -2625,7 +2630,7 @@ _public_ int sd_event_source_get_description(sd_event_source *s, const char **de
|
|||
return 0;
|
||||
}
|
||||
|
||||
_public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
|
||||
_public_ sd_event* sd_event_source_get_event(sd_event_source *s) {
|
||||
assert_return(s, NULL);
|
||||
assert_return(!event_origin_changed(s->event), NULL);
|
||||
|
||||
|
|
|
@ -472,11 +472,9 @@ static int add_connection_socket(Context *context, int fd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (context->idle_time) {
|
||||
r = sd_event_source_set_enabled(context->idle_time, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Unable to disable idle timer, continuing: %m");
|
||||
}
|
||||
r = sd_event_source_set_enabled(context->idle_time, SD_EVENT_OFF);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Unable to disable idle timer, continuing: %m");
|
||||
|
||||
c = new(Connection, 1);
|
||||
if (!c) {
|
||||
|
|
|
@ -123,7 +123,7 @@ sd_event_source* sd_event_source_ref(sd_event_source *s);
|
|||
sd_event_source* sd_event_source_unref(sd_event_source *s);
|
||||
sd_event_source* sd_event_source_disable_unref(sd_event_source *s);
|
||||
|
||||
sd_event *sd_event_source_get_event(sd_event_source *s);
|
||||
sd_event* sd_event_source_get_event(sd_event_source *s);
|
||||
void* sd_event_source_get_userdata(sd_event_source *s);
|
||||
void* sd_event_source_set_userdata(sd_event_source *s, void *userdata);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user