[systemd-commits] 4 commits - TODO src/core src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Aug 18 14:17:08 PDT 2014
TODO | 5 ++
src/core/unit.c | 92 +++++++++++++++++++++++++++++++++++++------------
src/shared/path-util.c | 11 +++++
3 files changed, 85 insertions(+), 23 deletions(-)
New commits:
commit 9da465df2a7d5d87e4af61364fb1475b1c8cbc6f
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Aug 18 23:16:18 2014 +0200
Update TODO
diff --git a/TODO b/TODO
index e85eb55..d387fa4 100644
--- a/TODO
+++ b/TODO
@@ -24,6 +24,11 @@ External:
Features:
+* logind: make the Suspend()/Hibernate() bus calls wait for the for
+ the job to be completed. before returning, so that clients can wait
+ for "systemctl suspend" to finish to know when the suspending is
+ complete.
+
* sd_notify("SHUTDOWN=1") to fix a dbus activation race.
http://lists.freedesktop.org/archives/systemd-devel/2014-July/020983.html
commit 70421bdce2719d76efffd8afdc28433c75aac5a2
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Aug 18 23:15:51 2014 +0200
util: try to be a bit more NFS compatible when checking whether an FS is writable
https://bugs.freedesktop.org/show_bug.cgi?id=81169
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 57554cd..67566bc 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -533,7 +533,16 @@ int path_is_read_only_fs(const char *path) {
if (statvfs(path, &st) < 0)
return -errno;
- return !!(st.f_flag & ST_RDONLY);
+ if (st.f_flag & ST_RDONLY)
+ return true;
+
+ /* On NFS, statvfs() might not reflect whether we can actually
+ * write to the remote share. Let's try again with
+ * access(W_OK) which is more reliable, at least sometimes. */
+ if (access(path, W_OK) < 0 && errno == EROFS)
+ return true;
+
+ return false;
}
int path_is_os_tree(const char *path) {
commit 3f3cc397043e69c9e9a690194a6a1043bf6466c5
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Aug 18 22:25:24 2014 +0200
core: minor modernizations
diff --git a/src/core/unit.c b/src/core/unit.c
index 950b83a..08e74b4 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1651,9 +1651,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
}
/* Keep track of failed units */
- if (ns == UNIT_FAILED && os != UNIT_FAILED)
+ if (ns == UNIT_FAILED)
set_put(u->manager->failed_units, u);
- else if (os == UNIT_FAILED && ns != UNIT_FAILED)
+ else
set_remove(u->manager->failed_units, u);
/* Make sure the cgroup is always removed when we become inactive */
@@ -1998,6 +1998,8 @@ bool unit_job_is_applicable(Unit *u, JobType j) {
}
static int maybe_warn_about_dependency(const char *id, const char *other, UnitDependency dependency) {
+ assert(id);
+
switch (dependency) {
case UNIT_REQUIRES:
case UNIT_REQUIRES_OVERRIDABLE:
@@ -2038,6 +2040,7 @@ static int maybe_warn_about_dependency(const char *id, const char *other, UnitDe
case _UNIT_DEPENDENCY_INVALID:
break;
}
+
assert_not_reached("Invalid dependency type");
}
@@ -2151,10 +2154,12 @@ int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit
assert(u);
- if ((r = unit_add_dependency(u, d, other, add_reference)) < 0)
+ r = unit_add_dependency(u, d, other, add_reference);
+ if (r < 0)
return r;
- if ((r = unit_add_dependency(u, e, other, add_reference)) < 0)
+ r = unit_add_dependency(u, e, other, add_reference);
+ if (r < 0)
return r;
return 0;
@@ -2214,22 +2219,22 @@ int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, con
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
+ _cleanup_free_ char *s = NULL;
Unit *other;
int r;
- _cleanup_free_ char *s = NULL;
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- r = unit_add_two_dependencies(u, d, e, other, add_reference);
-
- return r;
+ return unit_add_two_dependencies(u, d, e, other, add_reference);
}
int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
@@ -2240,15 +2245,15 @@ int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *n
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- r = unit_add_dependency(other, d, u, add_reference);
-
- return r;
+ return unit_add_dependency(other, d, u, add_reference);
}
int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
@@ -2259,13 +2264,16 @@ int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDep
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- if ((r = unit_add_two_dependencies(other, d, e, u, add_reference)) < 0)
+ r = unit_add_two_dependencies(other, d, e, u, add_reference);
+ if (r < 0)
return r;
return r;
commit ff50244582bf69e8489bba6ce59a21663d7f8274
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Aug 18 22:21:42 2014 +0200
units: fix BindsTo= logic when applied relative to services with Type=oneshot
Start jobs for Type=oneshot units are successful when the unit state
transition activating â inactive took place. In such a case all units
that BindsTo= on it previously would continue to run, even though the unit
they dependet on was actually already gone.
diff --git a/src/core/unit.c b/src/core/unit.c
index a5f6b2e..950b83a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1471,12 +1471,44 @@ static void unit_check_unneeded(Unit *u) {
if (unit_active_or_pending(other))
return;
- log_info_unit(u->id, "Service %s is not needed anymore. Stopping.", u->id);
+ log_info_unit(u->id, "Unit %s is not needed anymore. Stopping.", u->id);
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
}
+static void unit_check_binds_to(Unit *u) {
+ bool stop = false;
+ Unit *other;
+ Iterator i;
+
+ assert(u);
+
+ if (u->job)
+ return;
+
+ if (unit_active_state(u) != UNIT_ACTIVE)
+ return;
+
+ SET_FOREACH(other, u->dependencies[UNIT_BINDS_TO], i) {
+ if (other->job)
+ continue;
+
+ if (!UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other)))
+ continue;
+
+ stop = true;
+ }
+
+ if (!stop)
+ return;
+
+ log_info_unit(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id);
+
+ /* A unit we need to run is gone. Sniff. Let's stop this. */
+ manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
+}
+
static void retroactively_start_dependencies(Unit *u) {
Iterator i;
Unit *other;
@@ -1788,11 +1820,19 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
manager_recheck_journal(m);
unit_trigger_notify(u);
- /* Maybe we finished startup and are now ready for being
- * stopped because unneeded? */
- if (u->manager->n_reloading <= 0)
+ if (u->manager->n_reloading <= 0) {
+ /* Maybe we finished startup and are now ready for
+ * being stopped because unneeded? */
unit_check_unneeded(u);
+ /* Maybe we finished startup, but something we needed
+ * has vanished? Let's die then. (This happens when
+ * something BindsTo= to a Type=oneshot unit, as these
+ * units go directly from starting to inactive,
+ * without ever entering started.) */
+ unit_check_binds_to(u);
+ }
+
unit_add_to_dbus_queue(u);
unit_add_to_gc_queue(u);
}
More information about the systemd-commits
mailing list