mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	add naming to threads
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
		
							parent
							
								
									e2fcab34b7
								
							
						
					
					
						commit
						36473e3889
					
				
					 13 changed files with 38 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -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 {
 | 
			
		|||
 | 
			
		||||
	void HTTPServer::Run ()
 | 
			
		||||
	{
 | 
			
		||||
		pthread_setname_np(pthread_self(), "Webconsole");
 | 
			
		||||
		while (m_IsRunning)
 | 
			
		||||
		{
 | 
			
		||||
			try
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		|||
 | 
			
		||||
	void I2PControlService::Run ()
 | 
			
		||||
	{
 | 
			
		||||
		pthread_setname_np(pthread_self(), "I2PC");
 | 
			
		||||
		while (m_IsRunning)
 | 
			
		||||
		{
 | 
			
		||||
			try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		|||
 | 
			
		||||
	void UPnP::Run ()
 | 
			
		||||
	{
 | 
			
		||||
		pthread_setname_np(pthread_self(), "UPnP");
 | 
			
		||||
		while (m_IsRunning)
 | 
			
		||||
		{
 | 
			
		||||
			try
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,6 @@
 | 
			
		|||
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <thread>
 | 
			
		||||
#include <list>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <array>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,6 +94,7 @@ namespace util
 | 
			
		|||
 | 
			
		||||
	void RunnableService::Run ()
 | 
			
		||||
	{
 | 
			
		||||
		pthread_setname_np(pthread_self(), m_Name.c_str());
 | 
			
		||||
		while (m_IsRunning)
 | 
			
		||||
		{
 | 
			
		||||
			try
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
#include <cassert>
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#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<UDPConvo>(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<const Address> addr;
 | 
			
		||||
		while(!(addr = context.GetAddressBook().GetAddress(m_RemoteDest)) && !m_cancel_resolve)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue