mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
Make debug easier by naming threads.
This commit is contained in:
@@ -266,6 +266,7 @@ void JobQueue::threadEntry()
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
while (1)
|
||||
{
|
||||
NameThread("waiting");
|
||||
while (mJobSet.empty() && !mShuttingDown)
|
||||
mJobCond.wait(sl);
|
||||
|
||||
@@ -286,6 +287,7 @@ void JobQueue::threadEntry()
|
||||
|
||||
++(mJobCounts[type].second);
|
||||
sl.unlock();
|
||||
NameThread(Job::toString(type));
|
||||
cLog(lsTRACE) << "Doing " << Job::toString(type) << " job";
|
||||
job.doJob();
|
||||
} // must destroy job without holding lock
|
||||
|
||||
@@ -317,6 +317,7 @@ int LoadManager::getUptime()
|
||||
|
||||
void LoadManager::threadEntry()
|
||||
{
|
||||
NameThread("loadMgr");
|
||||
boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time();
|
||||
while (1)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
|
||||
|
||||
void WSDoor::startListening()
|
||||
{
|
||||
NameThread("websocket");
|
||||
// Generate a single SSL context for use by all connections.
|
||||
boost::shared_ptr<boost::asio::ssl::context> mCtx;
|
||||
mCtx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
|
||||
|
||||
@@ -127,6 +127,7 @@ void printHelp(const po::options_description& desc)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NameThread("main");
|
||||
int iResult = 0;
|
||||
po::variables_map vm; // Map of options.
|
||||
|
||||
@@ -248,6 +249,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
// No arguments. Run server.
|
||||
setupServer();
|
||||
NameThread("io");
|
||||
startServer();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "utils.h"
|
||||
#include "uint256.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
@@ -9,6 +13,9 @@
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "uint256.h"
|
||||
|
||||
void getRand(unsigned char *buf, int num)
|
||||
{
|
||||
if (RAND_bytes(buf, num) != 1)
|
||||
@@ -333,6 +340,39 @@ uint32_t be32toh(uint32_t value)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PR_SET_NAME
|
||||
#define HAVE_NAME_THREAD
|
||||
extern void NameThread(const char* n)
|
||||
{
|
||||
static std::string pName;
|
||||
|
||||
if (pName.empty())
|
||||
{
|
||||
std::ifstream cLine("/proc/self/cmdline", std::ios::in);
|
||||
cLine >> pName;
|
||||
if (pName.empty())
|
||||
pName = "rippled";
|
||||
else
|
||||
{
|
||||
size_t zero = pName.find_first_of('\0');
|
||||
if ((zero != std::string::npos) && (zero != 0))
|
||||
pName = pName.substr(0, zero - 1);
|
||||
size_t slash = pName.find_last_of('/');
|
||||
if (slash != std::string::npos)
|
||||
pName = pName.substr(slash + 1);
|
||||
}
|
||||
pName += " ";
|
||||
}
|
||||
|
||||
prctl(PR_SET_NAME, (pName + n).c_str(), 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NAME_THREAD
|
||||
extern void NameThread(const char*)
|
||||
{ ; }
|
||||
#endif
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( Utils)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( ParseUrl )
|
||||
|
||||
@@ -286,6 +286,8 @@ template<typename T, typename U> T range_check_cast(const U& value, const T& min
|
||||
|
||||
bool parseUrl(const std::string& strUrl, std::string& strScheme, std::string& strDomain, int& iPort, std::string& strPath);
|
||||
|
||||
extern void NameThread(const char *);
|
||||
|
||||
#if (!defined(FORCE_NO_C11X) && (__cplusplus > 201100L)) || defined(FORCE_C11X)
|
||||
|
||||
#define C11X
|
||||
|
||||
Reference in New Issue
Block a user