summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2015-07-24 22:25:28 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2015-07-24 22:30:26 +0200
commit3dbadf9ef96e76f1bc472660ba5435dc0fa27a66 (patch)
tree48ed4c851b05cecdfd1de2b02843843195208b88 /src/core
parent5f8ae398ae2ff71aacd85663e30eebb4ce0078f4 (diff)
automount: handle state changes of the corresponding mount unit correctly
The expire timeout must be started/stopped if the corresponding mount unit changes its state, e.g. it is started via local-fs.target or stopped by a manual umount.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index 1190b6cb64..4af381b4b6 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -471,13 +471,20 @@ static int automount_send_ready(Automount *a, Set *tokens, int status) {
return r;
}
+static int automount_start_expire(Automount *a);
+
int automount_update_mount(Automount *a, MountState old_state, MountState state) {
+ int r;
+
assert(a);
switch (state) {
case MOUNT_MOUNTED:
case MOUNT_REMOUNTING:
automount_send_ready(a, a->tokens, 0);
+ r = automount_start_expire(a);
+ if (r < 0)
+ log_unit_warning_errno(UNIT(a), r, "Failed to start expiration timer, ignoring: %m");
break;
case MOUNT_DEAD:
case MOUNT_UNMOUNTING:
@@ -490,6 +497,7 @@ int automount_update_mount(Automount *a, MountState old_state, MountState state)
case MOUNT_FAILED:
if (old_state != state)
automount_send_ready(a, a->tokens, -ENODEV);
+ (void) sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_OFF);
break;
default:
break;
@@ -633,8 +641,6 @@ static void *expire_thread(void *p) {
return NULL;
}
-static int automount_start_expire(Automount *a);
-
static int automount_dispatch_expire(sd_event_source *source, usec_t usec, void *userdata) {
Automount *a = AUTOMOUNT(userdata);
_cleanup_(expire_data_freep) struct expire_data *data = NULL;
@@ -733,10 +739,6 @@ static void automount_enter_runnning(Automount *a) {
}
}
- r = automount_start_expire(a);
- if (r < 0)
- log_unit_warning_errno(UNIT(a), r, "Failed to start expiration timer, ignoring: %m");
-
automount_set_state(a, AUTOMOUNT_RUNNING);
return;