Message ID | 1482896059-12020-1-git-send-email-zhang.zhanghailiang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Please follow the conventions for commit messages. QEMU commit messages start with a prefix that identifies the affected component. (Use git-log(1) to check what prefix other people have used for the file(s) you touched.) The commit message should be brief and doesn't need to be a full sentence. For example: qemu-thread: fix qemu_thread_set_name() race in qemu_thread_create() Thanks, Stefan
Oops, I deleted the original title carelessly, will send V2. Thanks. On 2017/1/4 0:06, Stefan Hajnoczi wrote: > Please follow the conventions for commit messages. QEMU commit messages > start with a prefix that identifies the affected component. > > (Use git-log(1) to check what prefix other people have used for the > file(s) you touched.) > > The commit message should be brief and doesn't need to be a full > sentence. > > For example: > > qemu-thread: fix qemu_thread_set_name() race in qemu_thread_create() > > Thanks, > Stefan
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index d20cdde..d31793d 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -481,12 +481,6 @@ void qemu_thread_create(QemuThread *thread, const char *name, if (err) { error_exit(err, __func__); } - if (mode == QEMU_THREAD_DETACHED) { - err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (err) { - error_exit(err, __func__); - } - } /* Leave signal handling to the iothread. */ sigfillset(&set); @@ -499,6 +493,12 @@ void qemu_thread_create(QemuThread *thread, const char *name, qemu_thread_set_name(thread, name); } + if (mode == QEMU_THREAD_DETACHED) { + err = pthread_detach(thread->thread); + if (err) { + error_exit(err, __func__); + } + } pthread_sigmask(SIG_SETMASK, &oldset, NULL); pthread_attr_destroy(&attr);