chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit: allow extension of unit files with .d/*.conf drop-ins
[elogind.git]
/
src
/
core
/
unit.c
diff --git
a/src/core/unit.c
b/src/core/unit.c
index 82dd617e35175cba8a3d71adb795932d4a8db647..f00cfedb89389ec45334ffff41e49fd0bafdb37a 100644
(file)
--- a/
src/core/unit.c
+++ b/
src/core/unit.c
@@
-1560,7
+1560,7
@@
void unit_unwatch_pid(Unit *u, pid_t pid) {
hashmap_remove_value(u->manager->watch_pids, LONG_TO_PTR(pid), u);
}
hashmap_remove_value(u->manager->watch_pids, LONG_TO_PTR(pid), u);
}
-int unit_watch_timer(Unit *u,
usec_t delay
, Watch *w) {
+int unit_watch_timer(Unit *u,
clockid_t clock_id, bool relative, usec_t usec
, Watch *w) {
struct itimerspec its;
int flags, fd;
bool ours;
struct itimerspec its;
int flags, fd;
bool ours;
@@
-1580,7
+1580,7
@@
int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
} else if (w->type == WATCH_INVALID) {
ours = true;
} else if (w->type == WATCH_INVALID) {
ours = true;
- fd = timerfd_create(
CLOCK_MONOTONIC
, TFD_NONBLOCK|TFD_CLOEXEC);
+ fd = timerfd_create(
clock_id
, TFD_NONBLOCK|TFD_CLOEXEC);
if (fd < 0)
return -errno;
} else
if (fd < 0)
return -errno;
} else
@@
-1588,7
+1588,7
@@
int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
zero(its);
zero(its);
- if (
delay
<= 0) {
+ if (
usec
<= 0) {
/* Set absolute time in the past, but not 0, since we
* don't want to disarm the timer */
its.it_value.tv_sec = 0;
/* Set absolute time in the past, but not 0, since we
* don't want to disarm the timer */
its.it_value.tv_sec = 0;
@@
-1596,8
+1596,8
@@
int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
flags = TFD_TIMER_ABSTIME;
} else {
flags = TFD_TIMER_ABSTIME;
} else {
- timespec_store(&its.it_value,
delay
);
- flags =
0
;
+ timespec_store(&its.it_value,
usec
);
+ flags =
relative ? 0 : TFD_TIMER_ABSTIME
;
}
/* This will also flush the elapse counter */
}
/* This will also flush the elapse counter */
@@
-1781,6
+1781,7
@@
static const char *resolve_template(Unit *u, const char *name, const char*path,
assert(u);
assert(name || path);
assert(u);
assert(name || path);
+ assert(p);
if (!name)
name = path_get_file_name(path);
if (!name)
name = path_get_file_name(path);
@@
-1795,7
+1796,8
@@
static const char *resolve_template(Unit *u, const char *name, const char*path,
else {
char *i;
else {
char *i;
- if (!(i = unit_name_to_prefix(u->id)))
+ i = unit_name_to_prefix(u->id);
+ if (!i)
return NULL;
s = unit_name_replace_instance(name, i);
return NULL;
s = unit_name_replace_instance(name, i);
@@
-1812,22
+1814,20
@@
static const char *resolve_template(Unit *u, const char *name, const char*path,
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
Unit *other;
int r;
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
Unit *other;
int r;
-
char *s
;
+
_cleanup_free_ char *s = NULL
;
assert(u);
assert(name || path);
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
- goto finish;
-
- r = unit_add_dependency(u, d, other, add_reference);
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
+ return r;
-finish:
- free(s);
- return r;
+ return unit_add_dependency(u, d, other, add_reference);
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {