From: Jianpeng Ma Date: Wed, 4 May 2016 10:03:53 +0000 (+0800) Subject: common/WorkQueue: Using pthread name instead pthread_self for heartbeat_handle_d... X-Git-Tag: v11.0.0~467^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=50c8c76d8a319a4b8594cb10003c55dc79440fb7;p=ceph.git common/WorkQueue: Using pthread name instead pthread_self for heartbeat_handle_d.name. Now most threads have their own thread name. So use pthread-name instead pthread_self to heartbeat_handle_d.name is more readable. Signed-off-by: Jianpeng Ma --- diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 0a0b601833a..85150e42471 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -94,7 +94,9 @@ void ThreadPool::worker(WorkThread *wt) ldout(cct,10) << "worker start" << dendl; std::stringstream ss; - ss << name << " thread " << (void*)pthread_self(); + char name[16] = {0}; + pthread_getname_np(pthread_self(), name, sizeof(name)); + ss << name << " thread " << name; heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self()); while (!_stop) { @@ -297,7 +299,9 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) ldout(cct,10) << "worker start" << dendl; std::stringstream ss; - ss << name << " thread " << (void*)pthread_self(); + char name[16] = {0}; + pthread_getname_np(pthread_self(), name, sizeof(name)); + ss << name << " thread " << name; heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self()); while (!stop_threads.read()) {