mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Log uncaught exceptions at the top of threads (RIPD-1166)
This commit is contained in:
committed by
Nik Bougalis
parent
7295d7f4bb
commit
fdd1f2ec36
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/core/DeadlineTimer.h>
|
||||
#include <ripple/core/ReportUncaughtException.h>
|
||||
#include <ripple/beast/core/Thread.h>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -97,7 +98,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void run ()
|
||||
void run () override
|
||||
{
|
||||
reportUncaughtException (
|
||||
this, &Manager::runImpl, "DeadlineTimer::Manager::run()");
|
||||
}
|
||||
|
||||
void runImpl ()
|
||||
{
|
||||
while (! threadShouldExit ())
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/core/Job.h>
|
||||
#include <ripple/core/ReportUncaughtException.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace ripple {
|
||||
@@ -76,14 +77,15 @@ bool Job::shouldCancel () const
|
||||
|
||||
void Job::doJob ()
|
||||
{
|
||||
m_loadEvent->start ();
|
||||
m_loadEvent->reName (mName);
|
||||
|
||||
mJob (*this);
|
||||
|
||||
// Destroy the lambda, otherwise we won't include
|
||||
// its duration in the time measurement
|
||||
mJob = std::function<void(Job&)>();
|
||||
reportUncaughtException (this, &Job::doJobImpl, "Job::doJob()",
|
||||
[this] ()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Job name: " << this->mName
|
||||
<< "; Job type: " << this->mType
|
||||
<< "; Job info: " << this->mJob.target_type().name();
|
||||
return ss.str();
|
||||
});
|
||||
}
|
||||
|
||||
void Job::rename (std::string const& newName)
|
||||
@@ -135,4 +137,16 @@ bool Job::operator<= (const Job& j) const
|
||||
return mJobIndex <= j.mJobIndex;
|
||||
}
|
||||
|
||||
void Job::doJobImpl ()
|
||||
{
|
||||
m_loadEvent->start ();
|
||||
m_loadEvent->reName (mName);
|
||||
|
||||
mJob (*this);
|
||||
|
||||
// Destroy the lambda, otherwise we won't include
|
||||
// its duration in the time measurement
|
||||
mJob = std::function<void(Job&)>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/core/impl/SNTPClock.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/ThreadName.h>
|
||||
#include <ripple/basics/random.h>
|
||||
#include <ripple/core/impl/SNTPClock.h>
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <ripple/beast/core/Thread.h>
|
||||
#include <ripple/core/ReportUncaughtException.h>
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <cmath>
|
||||
@@ -203,7 +204,12 @@ public:
|
||||
void doRun ()
|
||||
{
|
||||
setCallingThreadName("SNTPClock");
|
||||
io_service_.run();
|
||||
|
||||
// Get the address of an overloaded asio method
|
||||
using Pio_service_mem = std::size_t (boost::asio::io_service::*)();
|
||||
Pio_service_mem pRun = &boost::asio::io_service::run;
|
||||
|
||||
reportUncaughtException (&io_service_, pRun, "SNTPClientImp::doRun()");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/core/impl/Workers.h>
|
||||
#include <ripple/core/ReportUncaughtException.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <cassert>
|
||||
|
||||
@@ -156,6 +157,16 @@ Workers::Worker::~Worker ()
|
||||
}
|
||||
|
||||
void Workers::Worker::run ()
|
||||
{
|
||||
// Call runImpl() and report if any exceptions escape runImpl.
|
||||
reportUncaughtException (this, &Workers::Worker::runImpl,
|
||||
"Workers::Worker::run()", [this] ()
|
||||
{
|
||||
return "Thread: " + Thread::getThreadName();
|
||||
});
|
||||
}
|
||||
|
||||
void Workers::Worker::runImpl ()
|
||||
{
|
||||
while (! threadShouldExit ())
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
|
||||
Active: Running the task processing loop.
|
||||
Idle: Active, but blocked on waiting for a task.
|
||||
Pausd: Blocked waiting to exit or become active.
|
||||
Paused: Blocked waiting to exit or become active.
|
||||
*/
|
||||
class Worker
|
||||
: public beast::LockFreeStack <Worker>::Node
|
||||
@@ -127,7 +127,8 @@ private:
|
||||
~Worker ();
|
||||
|
||||
private:
|
||||
void run ();
|
||||
void run () override;
|
||||
void runImpl ();
|
||||
|
||||
private:
|
||||
Workers& m_workers;
|
||||
|
||||
Reference in New Issue
Block a user