More debug thread name fixes

This commit is contained in:
SChernykh 2025-03-16 14:39:56 +01:00
parent 2449366d87
commit a55858b44f
3 changed files with 28 additions and 9 deletions

View file

@ -80,8 +80,8 @@ void p2pool_usage()
"--rpc-ssl Enable SSL on RPC connections to the Monero node\n"
"--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)\n"
#endif
"--no-stratum-http Disable HTTP on Stratum ports\n"
"--help Show this help message\n\n"
"--no-stratum-http Disable HTTP on Stratum ports\n"
"--help Show this help message\n\n"
"Example command line:\n\n"
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",
p2pool::VERSION,

View file

@ -334,6 +334,8 @@ void MergeMiningClientTari::run()
{
LOGINFO(1, "worker thread ready");
set_thread_name("MM Tari poll");
using namespace std::chrono;
for (;;) {

View file

@ -616,15 +616,32 @@ void TCPServer::loop(void* data)
log_category_prefix = server->get_log_category();
{
char buf[64] = {};
log::Stream s(buf);
s << log_category_prefix;
size_t n = strlen(log_category_prefix);
if (s.m_pos > 0) {
buf[s.m_pos - 1] = '\0';
if (n > 1) {
// 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);
}
else {
set_thread_name("TCPServer");
}
set_thread_name(buf);
}
LOGINFO(1, "event loop started");