From: zqkkqz Date: Fri, 7 Aug 2015 02:49:45 +0000 (+0800) Subject: Common/Thread: pthread_attr_destroy(thread_attr) when done with it X-Git-Tag: v0.80.11~11^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=81bb6dd7de8a191c11c16b3cdc07355ef3434435;p=ceph.git Common/Thread: pthread_attr_destroy(thread_attr) when done with it When a thread attributes object is no longer required, it should be destroyed using the pthread_attr_destroy() function. Destroying a thread attributes object has no effect on threads that were created using that object. Fixes: #12570 Signed-off-by: zqkqkz zheng.qiankun@h3c.com (cherry picked from commit 9471bb838a420ef5f439191d87e5388fecccb9e6) --- diff --git a/src/common/Thread.cc b/src/common/Thread.cc index df526baa08d..9f09a92688b 100644 --- a/src/common/Thread.cc +++ b/src/common/Thread.cc @@ -113,6 +113,10 @@ int Thread::try_create(size_t stacksize) r = pthread_create(&thread_id, thread_attr, _entry_func, (void*)this); restore_sigset(&old_sigset); + if (thread_attr) { + pthread_attr_destroy(thread_attr); + } + return r; }