diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 9f420cf0..73849e4d 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -1312,6 +1313,7 @@ namespace http { void HTTPServer::Run () { + pthread_setname_np(pthread_self(), "Webconsole"); while (m_IsRunning) { try diff --git a/daemon/I2PControl.cpp b/daemon/I2PControl.cpp index e8c6e031..1fde9109 100644 --- a/daemon/I2PControl.cpp +++ b/daemon/I2PControl.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Crypto.h" #include "FS.h" @@ -131,6 +132,7 @@ namespace client void I2PControlService::Run () { + pthread_setname_np(pthread_self(), "I2PC"); while (m_IsRunning) { try { diff --git a/daemon/UPnP.cpp b/daemon/UPnP.cpp index 92a41011..0076ddd7 100644 --- a/daemon/UPnP.cpp +++ b/daemon/UPnP.cpp @@ -1,6 +1,7 @@ #ifdef USE_UPNP #include #include +#include #include #include @@ -60,6 +61,7 @@ namespace transport void UPnP::Run () { + pthread_setname_np(pthread_self(), "UPnP"); while (m_IsRunning) { try diff --git a/libi2pd/Log.cpp b/libi2pd/Log.cpp index a0014841..d7386642 100644 --- a/libi2pd/Log.cpp +++ b/libi2pd/Log.cpp @@ -7,6 +7,7 @@ */ #include "Log.h" +#include //for std::transform #include @@ -179,6 +180,7 @@ namespace log { void Log::Run () { + pthread_setname_np(pthread_self(), "Logging"); Reopen (); while (m_IsRunning) { diff --git a/libi2pd/NTCP2.h b/libi2pd/NTCP2.h index 351f17b5..5c9ecac9 100644 --- a/libi2pd/NTCP2.h +++ b/libi2pd/NTCP2.h @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/libi2pd/NetDb.cpp b/libi2pd/NetDb.cpp index e280e31b..66dac010 100644 --- a/libi2pd/NetDb.cpp +++ b/libi2pd/NetDb.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "I2PEndian.h" #include "Base.h" @@ -88,6 +89,8 @@ namespace data void NetDb::Run () { + pthread_setname_np(pthread_self(), "NetDB"); + uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0; while (m_IsRunning) { diff --git a/libi2pd/SSU.cpp b/libi2pd/SSU.cpp index d29f5cd7..a75306bb 100644 --- a/libi2pd/SSU.cpp +++ b/libi2pd/SSU.cpp @@ -7,6 +7,7 @@ */ #include +#include #include "Log.h" #include "Timestamp.h" #include "RouterContext.h" @@ -23,7 +24,7 @@ namespace transport { SSUServer::SSUServer (const boost::asio::ip::address & addr, int port): - m_OnlyV6(true), m_IsRunning(false), m_Thread (nullptr), + m_OnlyV6(true), m_IsRunning(false), m_Thread (nullptr), m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), m_EndpointV6 (addr, port), m_Socket (m_ReceiversService, m_Endpoint), @@ -36,7 +37,7 @@ namespace transport SSUServer::SSUServer (int port): m_OnlyV6(false), m_IsRunning(false), m_Thread (nullptr), - m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), + m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), m_Endpoint (boost::asio::ip::udp::v4 (), port), m_EndpointV6 (boost::asio::ip::udp::v6 (), port), m_Socket (m_ReceiversService), m_SocketV6 (m_ReceiversServiceV6), @@ -100,7 +101,7 @@ namespace transport if (context.SupportsV6 ()) { m_ReceiversThreadV6 = new std::thread (std::bind (&SSUServer::RunReceiversV6, this)); - if (!m_Thread) + if (!m_Thread) m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); m_ReceiversServiceV6.post (std::bind (&SSUServer::ReceiveV6, this)); ScheduleTerminationV6 (); @@ -142,6 +143,8 @@ namespace transport void SSUServer::Run () { + pthread_setname_np(pthread_self(), "SSU"); + while (m_IsRunning) { try @@ -157,6 +160,8 @@ namespace transport void SSUServer::RunReceivers () { + pthread_setname_np(pthread_self(), "SSUv4"); + while (m_IsRunning) { try @@ -179,6 +184,8 @@ namespace transport void SSUServer::RunReceiversV6 () { + pthread_setname_np(pthread_self(), "SSUv6"); + while (m_IsRunning) { try diff --git a/libi2pd/Timestamp.cpp b/libi2pd/Timestamp.cpp index 0490350e..db5c3946 100644 --- a/libi2pd/Timestamp.cpp +++ b/libi2pd/Timestamp.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "Config.h" #include "Log.h" #include "I2PEndian.h" @@ -148,6 +149,7 @@ namespace util void NTPTimeSync::Run () { + pthread_setname_np(pthread_self(), "Timesync"); while (m_IsRunning) { try diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index c6e90ad2..585ef8e0 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -6,6 +6,7 @@ * See full license text in LICENSE file at top of project tree */ +#include #include "Log.h" #include "Crypto.h" #include "RouterContext.h" @@ -59,6 +60,8 @@ namespace transport template void EphemeralKeysSupplier::Run () { + pthread_setname_np(pthread_self(), "Ephemerals"); + while (m_IsRunning) { int num, total = 0; @@ -272,6 +275,8 @@ namespace transport void Transports::Run () { + pthread_setname_np(pthread_self(), "Transports"); + while (m_IsRunning && m_Service) { try diff --git a/libi2pd/Tunnel.cpp b/libi2pd/Tunnel.cpp index ad918787..a5f20963 100644 --- a/libi2pd/Tunnel.cpp +++ b/libi2pd/Tunnel.cpp @@ -10,6 +10,7 @@ #include "I2PEndian.h" #include #include +#include #include #include #include "Crypto.h" @@ -472,6 +473,7 @@ namespace tunnel void Tunnels::Run () { + pthread_setname_np(pthread_self(), "Tunnels"); std::this_thread::sleep_for (std::chrono::seconds(1)); // wait for other parts are ready uint64_t lastTs = 0, lastPoolsTs = 0; diff --git a/libi2pd/util.cpp b/libi2pd/util.cpp index 24814ad3..e98f939f 100644 --- a/libi2pd/util.cpp +++ b/libi2pd/util.cpp @@ -94,6 +94,7 @@ namespace util void RunnableService::Run () { + pthread_setname_np(pthread_self(), m_Name.c_str()); while (m_IsRunning) { try diff --git a/libi2pd_client/AddressBook.cpp b/libi2pd_client/AddressBook.cpp index d695b8eb..6ecbddaf 100644 --- a/libi2pd_client/AddressBook.cpp +++ b/libi2pd_client/AddressBook.cpp @@ -748,6 +748,7 @@ namespace client void AddressBookSubscription::CheckUpdates () { + pthread_setname_np(pthread_self(), "Addressbook"); bool result = MakeRequest (); m_Book.DownloadComplete (result, m_Ident, m_Etag, m_LastModified); } diff --git a/libi2pd_client/I2PTunnel.cpp b/libi2pd_client/I2PTunnel.cpp index 081294c6..18b7c5a0 100644 --- a/libi2pd_client/I2PTunnel.cpp +++ b/libi2pd_client/I2PTunnel.cpp @@ -7,6 +7,7 @@ */ #include +#include #include "Base.h" #include "Log.h" #include "Destination.h" @@ -862,7 +863,7 @@ namespace client std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); dgram->SetRawReceiver(std::bind(&I2PUDPClientTunnel::HandleRecvFromI2PRaw, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); } void I2PUDPClientTunnel::Start() { @@ -891,11 +892,11 @@ namespace client } auto remotePort = m_RecvEndpoint.port(); if (!m_LastPort || m_LastPort != remotePort) - { + { auto itr = m_Sessions.find(remotePort); - if (itr != m_Sessions.end()) + if (itr != m_Sessions.end()) m_LastSession = itr->second; - else + else { m_LastSession = std::make_shared(boost::asio::ip::udp::endpoint(m_RecvEndpoint), 0); m_Sessions.emplace (remotePort, m_LastSession); @@ -941,6 +942,7 @@ namespace client void I2PUDPClientTunnel::TryResolving() { LogPrint(eLogInfo, "UDP Tunnel: Trying to resolve ", m_RemoteDest); + pthread_setname_np(pthread_self(), "UDP Resolver"); std::shared_ptr addr; while(!(addr = context.GetAddressBook().GetAddress(m_RemoteDest)) && !m_cancel_resolve)