Browse Source

add naming to threads

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1595/head
R4SAS 4 years ago
parent
commit
36473e3889
  1. 2
      daemon/HTTPServer.cpp
  2. 2
      daemon/I2PControl.cpp
  3. 2
      daemon/UPnP.cpp
  4. 2
      libi2pd/Log.cpp
  5. 1
      libi2pd/NTCP2.h
  6. 3
      libi2pd/NetDb.cpp
  7. 13
      libi2pd/SSU.cpp
  8. 2
      libi2pd/Timestamp.cpp
  9. 5
      libi2pd/Transports.cpp
  10. 2
      libi2pd/Tunnel.cpp
  11. 1
      libi2pd/util.cpp
  12. 1
      libi2pd_client/AddressBook.cpp
  13. 10
      libi2pd_client/I2PTunnel.cpp

2
daemon/HTTPServer.cpp

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include <iomanip>
#include <sstream>
#include <thread>
#include <pthread.h>
#include <memory>
#include <boost/asio.hpp>
@ -1312,6 +1313,7 @@ namespace http { @@ -1312,6 +1313,7 @@ namespace http {
void HTTPServer::Run ()
{
pthread_setname_np(pthread_self(), "Webconsole");
while (m_IsRunning)
{
try

2
daemon/I2PControl.cpp

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <pthread.h>
#include "Crypto.h"
#include "FS.h"
@ -131,6 +132,7 @@ namespace client @@ -131,6 +132,7 @@ namespace client
void I2PControlService::Run ()
{
pthread_setname_np(pthread_self(), "I2PC");
while (m_IsRunning)
{
try {

2
daemon/UPnP.cpp

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#ifdef USE_UPNP
#include <string>
#include <thread>
#include <pthread.h>
#include <boost/thread/thread.hpp>
#include <boost/asio.hpp>
@ -60,6 +61,7 @@ namespace transport @@ -60,6 +61,7 @@ namespace transport
void UPnP::Run ()
{
pthread_setname_np(pthread_self(), "UPnP");
while (m_IsRunning)
{
try

2
libi2pd/Log.cpp

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
*/
#include "Log.h"
#include <pthread.h>
//for std::transform
#include <algorithm>
@ -179,6 +180,7 @@ namespace log { @@ -179,6 +180,7 @@ namespace log {
void Log::Run ()
{
pthread_setname_np(pthread_self(), "Logging");
Reopen ();
while (m_IsRunning)
{

1
libi2pd/NTCP2.h

@ -11,7 +11,6 @@ @@ -11,7 +11,6 @@
#include <inttypes.h>
#include <memory>
#include <thread>
#include <list>
#include <map>
#include <array>

3
libi2pd/NetDb.cpp

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include <vector>
#include <boost/asio.hpp>
#include <stdexcept>
#include <pthread.h>
#include "I2PEndian.h"
#include "Base.h"
@ -88,6 +89,8 @@ namespace data @@ -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)
{

13
libi2pd/SSU.cpp

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
*/
#include <string.h>
#include <pthread.h>
#include "Log.h"
#include "Timestamp.h"
#include "RouterContext.h"
@ -23,7 +24,7 @@ namespace transport @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -179,6 +184,8 @@ namespace transport
void SSUServer::RunReceiversV6 ()
{
pthread_setname_np(pthread_self(), "SSUv6");
while (m_IsRunning)
{
try

2
libi2pd/Timestamp.cpp

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include <future>
#include <boost/asio.hpp>
#include <boost/algorithm/string.hpp>
#include <pthread.h>
#include "Config.h"
#include "Log.h"
#include "I2PEndian.h"
@ -148,6 +149,7 @@ namespace util @@ -148,6 +149,7 @@ namespace util
void NTPTimeSync::Run ()
{
pthread_setname_np(pthread_self(), "Timesync");
while (m_IsRunning)
{
try

5
libi2pd/Transports.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
* See full license text in LICENSE file at top of project tree
*/
#include <pthread.h>
#include "Log.h"
#include "Crypto.h"
#include "RouterContext.h"
@ -59,6 +60,8 @@ namespace transport @@ -59,6 +60,8 @@ namespace transport
template<typename Keys>
void EphemeralKeysSupplier<Keys>::Run ()
{
pthread_setname_np(pthread_self(), "Ephemerals");
while (m_IsRunning)
{
int num, total = 0;
@ -272,6 +275,8 @@ namespace transport @@ -272,6 +275,8 @@ namespace transport
void Transports::Run ()
{
pthread_setname_np(pthread_self(), "Transports");
while (m_IsRunning && m_Service)
{
try

2
libi2pd/Tunnel.cpp

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "I2PEndian.h"
#include <random>
#include <thread>
#include <pthread.h>
#include <algorithm>
#include <vector>
#include "Crypto.h"
@ -472,6 +473,7 @@ namespace tunnel @@ -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;

1
libi2pd/util.cpp

@ -94,6 +94,7 @@ namespace util @@ -94,6 +94,7 @@ namespace util
void RunnableService::Run ()
{
pthread_setname_np(pthread_self(), m_Name.c_str());
while (m_IsRunning)
{
try

1
libi2pd_client/AddressBook.cpp

@ -748,6 +748,7 @@ namespace client @@ -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);
}

10
libi2pd_client/I2PTunnel.cpp

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
*/
#include <cassert>
#include <pthread.h>
#include "Base.h"
#include "Log.h"
#include "Destination.h"
@ -862,7 +863,7 @@ namespace client @@ -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 @@ -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<UDPConvo>(boost::asio::ip::udp::endpoint(m_RecvEndpoint), 0);
m_Sessions.emplace (remotePort, m_LastSession);
@ -941,6 +942,7 @@ namespace client @@ -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<const Address> addr;
while(!(addr = context.GetAddressBook().GetAddress(m_RemoteDest)) && !m_cancel_resolve)

Loading…
Cancel
Save