]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Common/Thread: pthread_attr_destroy(thread_attr) when done with it 6325/head
authorzqkkqz <zheng.qiankun@h3c.com>
Fri, 7 Aug 2015 02:49:45 +0000 (10:49 +0800)
committerLoic Dachary <ldachary@redhat.com>
Tue, 20 Oct 2015 09:37:30 +0000 (11:37 +0200)
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)

src/common/Thread.cc

index df526baa08d0fc71550cbfa2bee08a3c57a3db73..9f09a92688b40094312c56e6be34ff6675210c06 100644 (file)
@@ -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;
 }