summaryrefslogtreecommitdiff
path: root/task-utils.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-07-27 20:24:29 +0800
committerDavid Sterba <dsterba@suse.com>2015-08-31 19:25:10 +0200
commitf156337dc8e5a11b6bd5492e6820ed3c455fc0e5 (patch)
tree1509a3b88f1006d3b660239cf56c393a97cfe909 /task-utils.c
parent867352bad9ecb6a08afe2668aeeacbd626400d4c (diff)
downloadbtrfs-progs-f156337dc8e5a11b6bd5492e6820ed3c455fc0e5.tar.gz
btrfs-progs: resst info->periodic.timer_fd's value after free
task_period_stop() is used to close a timer explicitly, to avoid the timer handle closed again by task_stop(), we should reset its value after close. Also add value-reset for info->id for safe. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'task-utils.c')
-rw-r--r--task-utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/task-utils.c b/task-utils.c
index 17fd573..768be94 100644
--- a/task-utils.c
+++ b/task-utils.c
@@ -64,10 +64,13 @@ void task_stop(struct task_info *info)
if (info->id > 0) {
pthread_cancel(info->id);
pthread_join(info->id, NULL);
+ info->id = -1;
}
- if (info->periodic.timer_fd)
+ if (info->periodic.timer_fd) {
close(info->periodic.timer_fd);
+ info->periodic.timer_fd = 0;
+ }
if (info->postfn)
info->postfn(info->private_data);
@@ -130,5 +133,6 @@ void task_period_stop(struct task_info *info)
if (info->periodic.timer_fd) {
timerfd_settime(info->periodic.timer_fd, 0, NULL, NULL);
close(info->periodic.timer_fd);
+ info->periodic.timer_fd = -1;
}
}