]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Common/Thread: pthread_attr_destroy(thread_attr) when done with it 6157/head
authorzqkkqz <zheng.qiankun@h3c.com>
Fri, 7 Aug 2015 02:49:45 +0000 (10:49 +0800)
committerLoic Dachary <ldachary@redhat.com>
Fri, 2 Oct 2015 14:00:29 +0000 (16:00 +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 da62b7a36e632a89baa12fdd5d962f2653449abf..5f64da6afcc4d3e6ae041fc3bad459c1cc4242b8 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;
 }