MySQL 8.0.30
Source Code Documentation
loader.cc File Reference
#include "mysql/harness/loader.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cassert>
#include <cctype>
#include <cstdarg>
#include <cstring>
#include <exception>
#include <map>
#include <mutex>
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <thread>
#include <dlfcn.h>
#include <pthread.h>
#include <unistd.h>
#include "builtin_plugins.h"
#include "designator.h"
#include "dim.h"
#include "exception.h"
#include "harness_assert.h"
#include "my_stacktrace.h"
#include "my_thread.h"
#include "mysql/harness/dynamic_loader.h"
#include "mysql/harness/filesystem.h"
#include "mysql/harness/logging/logging.h"
#include "mysql/harness/logging/registry.h"
#include "mysql/harness/plugin.h"
#include "mysql/harness/sd_notify.h"
#include "mysql/harness/stdx/monitor.h"
#include "mysql/harness/utility/string.h"
#include "utilities.h"
#include "my_compiler.h"

Namespaces

namespace  anonymous_namespace{loader.cc}
 
namespace  mysql_harness
 
namespace  unittest_backdoor
 

Macros

#define MYSQL_ROUTER_LOG_DOMAIN    ::mysql_harness::logging::kMainLogger
 
#define USE_POSIX_SIGNALS
 
#define __has_feature(x)   0
 

Functions

void request_application_shutdown (const ShutdownReason reason)
 request application shutdown. More...
 
void request_log_reopen (const std::string &dst)
 notify a "log_reopen" is requested with optional filename for old logfile. More...
 
bool log_reopen_completed ()
 check reopen completed More...
 
std::string log_reopen_get_error ()
 get last log reopen error More...
 
static void block_all_nonfatal_signals ()
 
static void register_fatal_signal_handler ()
 
void set_log_reopen_complete_callback (log_reopen_callback cb)
 Setter for the log reopen thread completion callback function. More...
 
void default_log_reopen_complete_cb (const std::string errmsg)
 The default implementation for log reopen thread completion callback function. More...
 
const AppInfo * mysql_harness::get_app_info (const PluginFuncEnv *env) noexcept
 
const ConfigSection * mysql_harness::get_config_section (const PluginFuncEnv *env) noexcept
 
bool mysql_harness::is_running (const PluginFuncEnv *env) noexcept
 
bool mysql_harness::wait_for_stop (const PluginFuncEnv *env, uint32_t milliseconds) noexcept
 
void mysql_harness::clear_running (PluginFuncEnv *env) noexcept
 
void mysql_harness::set_error (PluginFuncEnv *env, ErrorType error_type, const char *fmt,...) noexcept
 
template<class T >
mysql_harness::value_or (T a, T b)
 If a isn't set, return b. More...
 
static void mysql_harness::call_plugin_function (PluginFuncEnv *env, std::exception_ptr &eptr, void(*fptr)(PluginFuncEnv *), const char *fnc_name, const char *plugin_name, const char *plugin_key=nullptr) noexcept
 
static std::string mysql_harness::section_to_string (const ConfigSection *section)
 
static void mysql_harness::report_unsupported_option (const std::string &section, const std::string &option, const bool error_out)
 
void mysql_harness::on_service_ready (const std::string &name)
 
void mysql_harness::on_service_ready (PluginFuncEnv *plugin_env)
 
HARNESS_EXPORT void unittest_backdoor::set_shutdown_pending (bool shutdown_pending)
 

Variables

static std::atomic< size_t > num_of_non_ready_services {0}
 
static const char kLogReopenServiceName [] = "log_reopen"
 
static const char kSignalHandlerServiceName [] = "signal_handler"
 
static constexpr size_t supported_global_options_size = 20
 
static const std::array< const char *, supported_global_options_sizesupported_global_options
 
std::mutex we_might_shutdown_cond_mutex
 
std::condition_variable we_might_shutdown_cond
 
static std::atomic< ShutdownReasong_shutdown_pending {SHUTDOWN_NONE}
 
static std::string shutdown_fatal_error_message
 
std::mutex log_reopen_cond_mutex
 
std::condition_variable log_reopen_cond
 
Monitor< mysql_harness::LogReopenThread * > g_reopen_thread {nullptr}
 
static log_reopen_callback g_log_reopen_complete_callback_fp
 
const std::array< int, 6 > anonymous_namespace{loader.cc}::g_fatal_signals
 

Macro Definition Documentation

◆ __has_feature

#define __has_feature (   x)    0

◆ MYSQL_ROUTER_LOG_DOMAIN

#define MYSQL_ROUTER_LOG_DOMAIN    ::mysql_harness::logging::kMainLogger

◆ USE_POSIX_SIGNALS

#define USE_POSIX_SIGNALS

Function Documentation

◆ block_all_nonfatal_signals()

static void block_all_nonfatal_signals ( )
static

◆ default_log_reopen_complete_cb()

void default_log_reopen_complete_cb ( const std::string  errmsg)

The default implementation for log reopen thread completion callback function.

Parameters
errmsgError message. Empty string assumes successful completion.

◆ log_reopen_completed()

bool log_reopen_completed ( )

check reopen completed

◆ log_reopen_get_error()

std::string log_reopen_get_error ( )

get last log reopen error

◆ register_fatal_signal_handler()

static void register_fatal_signal_handler ( )
static

◆ request_application_shutdown()

void request_application_shutdown ( const ShutdownReason  reason)

request application shutdown.

Exceptions
std::system_errorsame as std::unique_lock::lock does

◆ request_log_reopen()

void request_log_reopen ( const std::string &  dst)

notify a "log_reopen" is requested with optional filename for old logfile.

Parameters
dstrename old logfile to filename before reopen
Exceptions
std::system_errorsame as std::unique_lock::lock does

◆ set_log_reopen_complete_callback()

void set_log_reopen_complete_callback ( log_reopen_callback  cb)

Setter for the log reopen thread completion callback function.

Parameters
cbFunction to call at completion.

Variable Documentation

◆ g_log_reopen_complete_callback_fp

log_reopen_callback g_log_reopen_complete_callback_fp
static
Initial value:
=
void default_log_reopen_complete_cb(const std::string errmsg)
The default implementation for log reopen thread completion callback function.
Definition: loader.cc:276

◆ g_reopen_thread

◆ g_shutdown_pending

std::atomic<ShutdownReason> g_shutdown_pending {SHUTDOWN_NONE}
static

◆ kLogReopenServiceName

const char kLogReopenServiceName[] = "log_reopen"
static

◆ kSignalHandlerServiceName

const char kSignalHandlerServiceName[] = "signal_handler"
static

◆ log_reopen_cond

std::condition_variable log_reopen_cond

◆ log_reopen_cond_mutex

std::mutex log_reopen_cond_mutex

◆ num_of_non_ready_services

std::atomic<size_t> num_of_non_ready_services {0}
static

◆ shutdown_fatal_error_message

std::string shutdown_fatal_error_message
static

◆ supported_global_options

const std::array<const char *, supported_global_options_size> supported_global_options
static
Initial value:
{"origin",
"program",
"logging_folder",
"runtime_folder",
"data_folder",
"plugin_folder",
"config_folder",
"keyring_path",
"master_key_path",
"connect_timeout",
"read_timeout",
"dynamic_state",
"client_ssl_cert",
"client_ssl_key",
"client_ssl_mode",
"server_ssl_mode",
"server_ssl_verify",
"max_total_connections",
"pid_file",
"unknown_config_option",
}

◆ supported_global_options_size

constexpr size_t supported_global_options_size = 20
staticconstexpr

◆ we_might_shutdown_cond

std::condition_variable we_might_shutdown_cond

◆ we_might_shutdown_cond_mutex

std::mutex we_might_shutdown_cond_mutex