pid1: rename unit_check_gc to unit_may_gc
"check" is unclear: what is true, what is false? Let's rename to "can_gc" and
revert the return value ("positive" values are easier to grok).
v2:
- rename from unit_can_gc to unit_may_gc
This commit is contained in:
+18
-18
@@ -336,20 +336,21 @@ int unit_set_description(Unit *u, const char *description) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool unit_check_gc(Unit *u) {
|
||||
bool unit_may_gc(Unit *u) {
|
||||
UnitActiveState state;
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
|
||||
/* Checks whether the unit is ready to be unloaded for garbage collection. Returns true, when the unit shall
|
||||
* stay around, false if there's no reason to keep it loaded. */
|
||||
/* Checks whether the unit is ready to be unloaded for garbage collection.
|
||||
* Returns true when the unit may be collected, and false if there's some
|
||||
* reason to keep it loaded. */
|
||||
|
||||
if (u->job)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (u->nop_job)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
state = unit_active_state(u);
|
||||
|
||||
@@ -359,26 +360,26 @@ bool unit_check_gc(Unit *u) {
|
||||
UNIT_VTABLE(u)->release_resources(u);
|
||||
|
||||
if (u->perpetual)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (u->refs)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (sd_bus_track_count(u->bus_track) > 0)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
/* But we keep the unit object around for longer when it is referenced or configured to not be gc'ed */
|
||||
switch (u->collect_mode) {
|
||||
|
||||
case COLLECT_INACTIVE:
|
||||
if (state != UNIT_INACTIVE)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case COLLECT_INACTIVE_OR_FAILED:
|
||||
if (!IN_SET(state, UNIT_INACTIVE, UNIT_FAILED))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
@@ -394,14 +395,13 @@ bool unit_check_gc(Unit *u) {
|
||||
if (r < 0)
|
||||
log_unit_debug_errno(u, r, "Failed to determine whether cgroup %s is empty: %m", u->cgroup_path);
|
||||
if (r <= 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UNIT_VTABLE(u)->check_gc)
|
||||
if (UNIT_VTABLE(u)->check_gc(u))
|
||||
return true;
|
||||
if (UNIT_VTABLE(u)->may_gc && !UNIT_VTABLE(u)->may_gc(u))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void unit_add_to_load_queue(Unit *u) {
|
||||
@@ -431,7 +431,7 @@ void unit_add_to_gc_queue(Unit *u) {
|
||||
if (u->in_gc_queue || u->in_cleanup_queue)
|
||||
return;
|
||||
|
||||
if (unit_check_gc(u))
|
||||
if (!unit_may_gc(u))
|
||||
return;
|
||||
|
||||
LIST_PREPEND(gc_queue, u->manager->gc_unit_queue, u);
|
||||
@@ -1119,7 +1119,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
"%s\tActive Enter Timestamp: %s\n"
|
||||
"%s\tActive Exit Timestamp: %s\n"
|
||||
"%s\tInactive Enter Timestamp: %s\n"
|
||||
"%s\tGC Check Good: %s\n"
|
||||
"%s\tMay GC: %s\n"
|
||||
"%s\tNeed Daemon Reload: %s\n"
|
||||
"%s\tTransient: %s\n"
|
||||
"%s\tPerpetual: %s\n"
|
||||
@@ -1137,7 +1137,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->active_enter_timestamp.realtime)),
|
||||
prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->active_exit_timestamp.realtime)),
|
||||
prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->inactive_enter_timestamp.realtime)),
|
||||
prefix, yes_no(unit_check_gc(u)),
|
||||
prefix, yes_no(unit_may_gc(u)),
|
||||
prefix, yes_no(unit_need_daemon_reload(u)),
|
||||
prefix, yes_no(u->transient),
|
||||
prefix, yes_no(u->perpetual),
|
||||
|
||||
Reference in New Issue
Block a user