1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +03:00

core: rebreak a few comments

This commit is contained in:
Lennart Poettering 2021-04-13 17:26:16 +02:00
parent 15ed3c3a18
commit defe63b0f3
4 changed files with 41 additions and 54 deletions

View File

@ -2358,22 +2358,19 @@ static int unit_realize_cgroup_now_disable(Unit *u, ManagerState state) {
if (UNIT_DEREF(m->slice) != u)
continue;
/* The cgroup for this unit might not actually be fully
* realised yet, in which case it isn't holding any controllers
* open anyway. */
/* The cgroup for this unit might not actually be fully realised yet, in which case it isn't
* holding any controllers open anyway. */
if (!m->cgroup_realized)
continue;
/* We must disable those below us first in order to release the
* controller. */
/* We must disable those below us first in order to release the controller. */
if (m->type == UNIT_SLICE)
(void) unit_realize_cgroup_now_disable(m, state);
target_mask = unit_get_target_mask(m);
enable_mask = unit_get_enable_mask(m);
/* We can only disable in this direction, don't try to enable
* anything. */
/* We can only disable in this direction, don't try to enable anything. */
if (unit_has_mask_disables_realized(m, target_mask, enable_mask))
continue;
@ -2535,8 +2532,8 @@ void unit_add_family_to_cgroup_realize_queue(Unit *u) {
if (!m->cgroup_realized)
continue;
/* If the unit doesn't need any new controllers and has current ones realized, it
* doesn't need any changes. */
/* If the unit doesn't need any new controllers and has current ones
* realized, it doesn't need any changes. */
if (unit_has_mask_realized(m,
unit_get_target_mask(m),
unit_get_enable_mask(m)))

View File

@ -1014,26 +1014,22 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
job_fail_dependencies(u, UNIT_ATOM_PROPAGATE_STOP_FAILURE);
}
/* A special check to make sure we take down anything RequisiteOf if we
* aren't active. This is when the verify-active job merges with a
* satisfying job type, and then loses it's invalidation effect, as the
* result there is JOB_DONE for the start job we merged into, while we
* should be failing the depending job if the said unit isn't in fact
* active. Oneshots are an example of this, where going directly from
* activating to inactive is success.
/* A special check to make sure we take down anything RequisiteOf= if we aren't active. This is when
* the verify-active job merges with a satisfying job type, and then loses it's invalidation effect,
* as the result there is JOB_DONE for the start job we merged into, while we should be failing the
* depending job if the said unit isn't in fact active. Oneshots are an example of this, where going
* directly from activating to inactive is success.
*
* This happens when you use ConditionXYZ= in a unit too, since in that
* case the job completes with the JOB_DONE result, but the unit never
* really becomes active. Note that such a case still involves merging:
* This happens when you use ConditionXYZ= in a unit too, since in that case the job completes with
* the JOB_DONE result, but the unit never really becomes active. Note that such a case still
* involves merging:
*
* A start job waits for something else, and a verify-active comes in
* and merges in the installed job. Then, later, when it becomes
* runnable, it finishes with JOB_DONE result as execution on conditions
* not being met is skipped, breaking our dependency semantics.
* A start job waits for something else, and a verify-active comes in and merges in the installed
* job. Then, later, when it becomes runnable, it finishes with JOB_DONE result as execution on
* conditions not being met is skipped, breaking our dependency semantics.
*
* Also, depending on if start job waits or not, the merging may or may
* not happen (the verify-active job may trigger after it finishes), so
* you get undeterministic results without this check.
* Also, depending on if start job waits or not, the merging may or may not happen (the verify-active
* job may trigger after it finishes), so you get undeterministic results without this check.
*/
if (result == JOB_DONE && recursive &&
IN_SET(t, JOB_START, JOB_RELOAD) &&
@ -1656,8 +1652,7 @@ const char* job_type_to_access_method(JobType t) {
* stop a + start b 1st step stop a, 2nd step start b
* stop a + stop b 1st step stop b, 2nd step stop a
*
* This has the side effect that restarts are properly
* synchronized too.
* This has the side effect that restarts are properly synchronized too.
*/
int job_compare(Job *a, Job *b, UnitDependencyAtom assume_dep) {
assert(a);
@ -1676,9 +1671,8 @@ int job_compare(Job *a, Job *b, UnitDependencyAtom assume_dep) {
if (assume_dep == UNIT_ATOM_AFTER)
return -job_compare(b, a, UNIT_ATOM_BEFORE);
/* Let's make it simple, JOB_STOP goes always first (in case both ua and ub stop,
* then ub's stop goes first anyway).
* JOB_RESTART is JOB_STOP in disguise (before it is patched to JOB_START). */
/* Let's make it simple, JOB_STOP goes always first (in case both ua and ub stop, then ub's stop goes
* first anyway). JOB_RESTART is JOB_STOP in disguise (before it is patched to JOB_START). */
if (IN_SET(b->type, JOB_STOP, JOB_RESTART))
return 1;
else

View File

@ -359,8 +359,8 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
assert(j);
assert(!j->transaction_prev);
/* Does a recursive sweep through the ordering graph, looking
* for a cycle. If we find a cycle we try to break it. */
/* Does a recursive sweep through the ordering graph, looking for a cycle. If we find a cycle we try
* to break it. */
/* Have we seen this before? */
if (j->generation == generation) {
@ -368,18 +368,14 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
_cleanup_free_ char **array = NULL, *unit_ids = NULL;
char **unit_id, **job_type;
/* If the marker is NULL we have been here already and
* decided the job was loop-free from here. Hence
* shortcut things and return right-away. */
/* If the marker is NULL we have been here already and decided the job was loop-free from
* here. Hence shortcut things and return right-away. */
if (!j->marker)
return 0;
/* So, the marker is not NULL and we already have been here. We have
* a cycle. Let's try to break it. We go backwards in our path and
* try to find a suitable job to remove. We use the marker to find
* our way back, since smart how we are we stored our way back in
* there. */
/* So, the marker is not NULL and we already have been here. We have a cycle. Let's try to
* break it. We go backwards in our path and try to find a suitable job to remove. We use the
* marker to find our way back, since smart how we are we stored our way back in there. */
for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
/* For logging below */
@ -457,9 +453,8 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
/* Is there a job for this unit? */
o = hashmap_get(tr->jobs, u);
if (!o) {
/* Ok, there is no job for this in the
* transaction, but maybe there is already one
* running? */
/* Ok, there is no job for this in the transaction, but maybe there is
* already one running? */
o = u->job;
if (!o)
continue;

View File

@ -1730,10 +1730,11 @@ static bool unit_verify_deps(Unit *u) {
assert(u);
/* Checks whether all BindsTo= dependencies of this unit are fulfilled — if they are also combined with
* After=. We do not check Requires= or Requisite= here as they only should have an effect on the job
* processing, but do not have any effect afterwards. We don't check BindsTo= dependencies that are not used in
* conjunction with After= as for them any such check would make things entirely racy. */
/* Checks whether all BindsTo= dependencies of this unit are fulfilled — if they are also combined
* with After=. We do not check Requires= or Requisite= here as they only should have an effect on
* the job processing, but do not have any effect afterwards. We don't check BindsTo= dependencies
* that are not used in conjunction with After= as for them any such check would make things entirely
* racy. */
UNIT_FOREACH_DEPENDENCY(other, u, UNIT_ATOM_CANNOT_BE_ACTIVE_WITHOUT) {
@ -2875,7 +2876,7 @@ int unit_add_dependency(
[UNIT_TRIGGERED_BY] = UNIT_TRIGGERS,
[UNIT_PROPAGATES_RELOAD_TO] = UNIT_RELOAD_PROPAGATED_FROM,
[UNIT_RELOAD_PROPAGATED_FROM] = UNIT_PROPAGATES_RELOAD_TO,
[UNIT_JOINS_NAMESPACE_OF] = UNIT_JOINS_NAMESPACE_OF,
[UNIT_JOINS_NAMESPACE_OF] = UNIT_JOINS_NAMESPACE_OF, /* symmetric! 👓 */
};
Unit *original_u = u, *original_other = other;
UnitDependencyAtom a;
@ -4924,10 +4925,10 @@ void unit_remove_dependencies(Unit *u, UnitDependencyMask mask) {
di.origin_mask &= ~mask;
unit_update_dependency_mask(deps, other, di);
/* We updated the dependency from our unit to the other unit now. But most dependencies
* imply a reverse dependency. Hence, let's delete that one too. For that we go through
* all dependency types on the other unit and delete all those which point to us and
* have the right mask set. */
/* We updated the dependency from our unit to the other unit now. But most
* dependencies imply a reverse dependency. Hence, let's delete that one
* too. For that we go through all dependency types on the other unit and
* delete all those which point to us and have the right mask set. */
HASHMAP_FOREACH(other_deps, other->dependencies) {
UnitDependencyInfo dj;