summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-11-22 00:38:55 +0100
committerLennart Poettering <lennart@poettering.net>2012-11-22 00:45:22 +0100
commit68b29a9fca915c83b9192790ec61189430cd5de6 (patch)
tree6f1d6f6e049aab2194ac66398bc304068daa3694
parent0b2665c33de93d576047bf55ecff9e1435033f54 (diff)
manager: introduce watch_init() initializer for watches
-rw-r--r--src/core/manager.c10
-rw-r--r--src/core/manager.h2
-rw-r--r--src/core/service.c4
-rw-r--r--src/core/unit.c3
4 files changed, 15 insertions, 4 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index f932c79a1b..72ce2f2595 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1363,7 +1363,8 @@ static int process_event(Manager *m, struct epoll_event *ev) {
ssize_t k;
/* Some timer event, to be dispatched to the units */
- if ((k = read(w->fd, &v, sizeof(v))) != sizeof(v)) {
+ k = read(w->fd, &v, sizeof(v));
+ if (k != sizeof(v)) {
if (k < 0 && (errno == EINTR || errno == EAGAIN))
break;
@@ -2307,3 +2308,10 @@ bool manager_get_show_status(Manager *m) {
return plymouth_running();
}
+
+void watch_init(Watch *w) {
+ assert(w);
+
+ w->type = WATCH_INVALID;
+ w->fd = -1;
+}
diff --git a/src/core/manager.h b/src/core/manager.h
index 22145024f1..1644bd6f77 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -291,3 +291,5 @@ void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, bool b);
bool manager_get_show_status(Manager *m);
+
+void watch_init(Watch *w);
diff --git a/src/core/service.c b/src/core/service.c
index aad6d66439..34d24ffa92 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -127,9 +127,9 @@ static void service_init(Unit *u) {
s->restart_usec = DEFAULT_RESTART_USEC;
s->type = _SERVICE_TYPE_INVALID;
- s->watchdog_watch.type = WATCH_INVALID;
+ watch_init(&s->watchdog_watch);
+ watch_init(&s->timer_watch);
- s->timer_watch.type = WATCH_INVALID;
#ifdef HAVE_SYSV_COMPAT
s->sysv_start_priority = -1;
s->sysv_start_priority_from_rcnd = -1;
diff --git a/src/core/unit.c b/src/core/unit.c
index 99e1c27948..82dd617e35 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1580,7 +1580,8 @@ int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
} else if (w->type == WATCH_INVALID) {
ours = true;
- if ((fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC)) < 0)
+ fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC);
+ if (fd < 0)
return -errno;
} else
assert_not_reached("Invalid watch type");