Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/brpc/details/usercode_backup_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ UserCodeBackupPool::UserCodeBackupPool()
}

static void* UserCodeRunner(void* args) {
butil::PlatformThread::SetName("brpc_user_code_runner");
butil::PlatformThread::SetNameSimple("brpc_user_code_runner");
static_cast<UserCodeBackupPool*>(args)->UserCodeRunningLoop();
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/bthread/execution_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void* ExecutionQueueBase::_execute_tasks(void* arg) {
}

void* ExecutionQueueBase::_execute_tasks_pthread(void* arg) {
butil::PlatformThread::SetName("ExecutionQueue");
butil::PlatformThread::SetNameSimple("ExecutionQueue");
auto head = (TaskNode*)arg;
auto m = (ExecutionQueueBase*)head->q;
m->_current_head = head;
Expand Down
2 changes: 1 addition & 1 deletion src/bthread/task_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void* TaskControl::worker_thread(void* arg) {
std::string worker_thread_name = butil::string_printf(
"brpc_wkr:%d-%d", g->tag(),
c->_next_worker_id.fetch_add(1, butil::memory_order_relaxed));
butil::PlatformThread::SetName(worker_thread_name.c_str());
butil::PlatformThread::SetNameSimple(worker_thread_name.c_str());
}
BT_VLOG << "Created worker=" << pthread_self() << " tid=" << g->_tid
<< " bthread=" << g->main_tid() << " tag=" << g->tag();
Expand Down
2 changes: 1 addition & 1 deletion src/bthread/timer_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ inline bool task_greater(const TimerThread::Task* a, const TimerThread::Task* b)
}

void* TimerThread::run_this(void* arg) {
butil::PlatformThread::SetName("brpc_timer");
butil::PlatformThread::SetNameSimple("brpc_timer");
static_cast<TimerThread*>(arg)->run();
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions src/butil/threading/platform_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class BUTIL_EXPORT PlatformThread {
// otherwise. This name pointer is not copied internally. Thus, it must stay
// valid until the thread ends.
static void SetName(const char* name);
static void SetNameSimple(const char* name);

// Gets the thread name, if previously set by SetName.
static const char* GetName();
Expand Down
5 changes: 5 additions & 0 deletions src/butil/threading/platform_thread_freebsd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void PlatformThread::SetName(const char* name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);

SetNameSimple(name);
}

// static
void PlatformThread::SetNameSimple(const char* name) {
#if !defined(OS_NACL)
// On FreeBSD we can get the thread names to show up in the debugger by
// setting the process name for the LWP. We don't want to do this for the
Expand Down
4 changes: 4 additions & 0 deletions src/butil/threading/platform_thread_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ int ThreadNiceValue(ThreadPriority priority) {
void PlatformThread::SetName(const char* name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);

SetNameSimple(name);
}
// static
void PlatformThread::SetNameSimple(const char* name) {
#if !defined(OS_NACL)
// On linux we can get the thread names to show up in the debugger by setting
// the process name for the LWP. We don't want to do this for the main
Expand Down
5 changes: 5 additions & 0 deletions src/butil/threading/platform_thread_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ void InitThreading() {
// TODO: add tracked_objects related headers
//tracked_objects::ThreadData::InitializeThreadContext(name);

SetNameSimple(name);
}

// static
void PlatformThread::SetNameSimple(const char* name) {
// Mac OS X does not expose the length limit of the name, so
// hardcode it.
const int kMaxNameLength = 63;
Expand Down
4 changes: 2 additions & 2 deletions src/bvar/collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class Collector : public bvar::Reducer<Collected*, CombineCollected> {
int64_t interval_us);

static void* run_grab_thread(void* arg) {
butil::PlatformThread::SetName("bvar_collector_grabber");
butil::PlatformThread::SetNameSimple("bvar_collector_grabber");
static_cast<Collector*>(arg)->grab_thread();
return NULL;
}

static void* run_dump_thread(void* arg) {
butil::PlatformThread::SetName("bvar_collector_dumper");
butil::PlatformThread::SetNameSimple("bvar_collector_dumper");
static_cast<Collector*>(arg)->dump_thread();
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/bvar/detail/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SamplerCollector : public bvar::Reducer<Sampler*, CombineSampler> {
void run();

static void* sampling_thread(void* arg) {
butil::PlatformThread::SetName("bvar_sampler");
butil::PlatformThread::SetNameSimple("bvar_sampler");
static_cast<SamplerCollector*>(arg)->run();
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/bvar/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ static GFlag s_gflag_bvar_dump_interval("bvar_dump_interval");
static void* dumping_thread(void*) {
// NOTE: this variable was declared as static <= r34381, which was
// destructed when program exits and caused coredumps.
butil::PlatformThread::SetName("bvar_dumper");
butil::PlatformThread::SetNameSimple("bvar_dumper");
const std::string command_name = read_command_name();
std::string last_filename;
std::string mbvar_last_filename;
Expand Down
Loading