add naming to threads

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2020-12-04 18:36:49 +03:00
parent e2fcab34b7
commit 36473e3889
13 changed files with 38 additions and 8 deletions

View file

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

View file

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

View file

@ -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
void NetDb::Run ()
{
pthread_setname_np(pthread_self(), "NetDB");
uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0;
while (m_IsRunning)
{

View file

@ -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
{
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

View file

@ -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
void NTPTimeSync::Run ()
{
pthread_setname_np(pthread_self(), "Timesync");
while (m_IsRunning)
{
try

View file

@ -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
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
void Transports::Run ()
{
pthread_setname_np(pthread_self(), "Transports");
while (m_IsRunning && m_Service)
{
try

View file

@ -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
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;

View file

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