]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/WorkQueue: Using pthread name instead pthread_self for heartbeat_handle_d... 7070/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Wed, 4 May 2016 10:03:53 +0000 (18:03 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Thu, 5 May 2016 10:15:07 +0000 (18:15 +0800)
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 <jianpeng.ma@intel.com>
src/common/WorkQueue.cc

index 0a0b601833a656e212e9ed4a9c2232c2b8e3218d..85150e42471a653131b3460680806b78e8801e22 100644 (file)
@@ -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()) {