More debug thread name fixes
This commit is contained in:
@@ -334,6 +334,8 @@ void MergeMiningClientTari::run()
|
|||||||
{
|
{
|
||||||
LOGINFO(1, "worker thread ready");
|
LOGINFO(1, "worker thread ready");
|
||||||
|
|
||||||
|
set_thread_name("MM Tari poll");
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|||||||
+22
-5
@@ -616,16 +616,33 @@ void TCPServer::loop(void* data)
|
|||||||
|
|
||||||
log_category_prefix = server->get_log_category();
|
log_category_prefix = server->get_log_category();
|
||||||
{
|
{
|
||||||
char buf[64] = {};
|
size_t n = strlen(log_category_prefix);
|
||||||
log::Stream s(buf);
|
|
||||||
s << log_category_prefix;
|
|
||||||
|
|
||||||
if (s.m_pos > 0) {
|
if (n > 1) {
|
||||||
buf[s.m_pos - 1] = '\0';
|
// Discard the last character (space)
|
||||||
|
--n;
|
||||||
|
|
||||||
|
char buf[16] = {};
|
||||||
|
|
||||||
|
if (n < sizeof(buf)) {
|
||||||
|
// Set the thread name as is
|
||||||
|
memcpy(buf, log_category_prefix, n);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Thread name is too long, use the "first 7 characters - last 7 characters" format
|
||||||
|
constexpr size_t k = sizeof(buf) / 2 - 1;
|
||||||
|
|
||||||
|
memcpy(buf, log_category_prefix, k);
|
||||||
|
buf[k] = '-';
|
||||||
|
memcpy(buf + k + 1, log_category_prefix + n - k, k);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_thread_name(buf);
|
set_thread_name(buf);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
set_thread_name("TCPServer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOGINFO(1, "event loop started");
|
LOGINFO(1, "event loop started");
|
||||||
server_event_loop_thread = data;
|
server_event_loop_thread = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user