0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

RunContext: added process_exception() helper method

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2021-07-17 21:37:54 -06:00 committed by Antonio Quartulli
parent 5231fa35ad
commit 5a9fd26be7
No known key found for this signature in database
GPG Key ID: 20C8E22F5B1610AB

View File

@ -48,6 +48,7 @@
#include <openvpn/common/environ.hpp>
#include <openvpn/common/number.hpp>
#include <openvpn/common/signal_name.hpp>
#include <openvpn/common/pthreadcond.hpp>
#include <openvpn/asio/asiosignal.hpp>
#include <openvpn/time/time.hpp>
#include <openvpn/time/asiotimer.hpp>
@ -250,6 +251,26 @@ namespace openvpn {
}
}
template <typename SVC>
void process_exception(const std::string& thread_name,
const unsigned int unit,
const bool io_context_run_called,
openvpn_io::io_context& io_context,
SVC& svc,
PThreadBarrier& event_loop_bar,
const std::exception& e)
{
event_loop_bar.error();
if (svc)
{
clear_server(unit);
svc->stop(); // on exception, stop service,
}
if (io_context_run_called)
io_context.poll(); // execute completion handlers,
OPENVPN_LOG(thread_name << " thread exception: " << e.what());
}
virtual void log(const std::string& str) override
{
time_t now;