From 81bb6dd7de8a191c11c16b3cdc07355ef3434435 Mon Sep 17 00:00:00 2001 From: zqkkqz Date: Fri, 7 Aug 2015 10:49:45 +0800 Subject: [PATCH] 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) --- src/common/Thread.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/Thread.cc b/src/common/Thread.cc index df526baa08d0f..9f09a92688b40 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; } -- 2.39.5