Message ID | 5e15e8e8a85b4877cb913d0e437d2a9b48c85594.1437977968.git.zhaolei@cn.fujitsu.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
diff --git a/task-utils.c b/task-utils.c index 10e3f0f..0390a69 100644 --- a/task-utils.c +++ b/task-utils.c @@ -50,9 +50,7 @@ int task_start(struct task_info *info) ret = pthread_create(&info->id, NULL, info->threadfn, info->private_data); - if (ret == 0) - pthread_detach(info->id); - else + if (ret) info->id = -1; return ret; @@ -66,8 +64,10 @@ void task_stop(struct task_info *info) if (info->periodic.timer_fd) close(info->periodic.timer_fd); - if (info->id > 0) + if (info->id > 0) { pthread_cancel(info->id); + pthread_join(info->id, NULL); + } if (info->postfn) info->postfn(info->private_data);