MySQL 8.0.39
Source Code Documentation
|
#include "sql/conn_handler/socket_connection.h"
#include "my_config.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include <algorithm>
#include <atomic>
#include <memory>
#include <new>
#include <utility>
#include "m_string.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_sys.h"
#include "my_thread.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/psi/mysql_thread.h"
#include "mysqld_error.h"
#include "sql-common/net_ns.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/conn_handler/channel_info.h"
#include "sql/conn_handler/init_net_server_extension.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "violite.h"
#include <sys/un.h>
#include "connection_handler_manager.h"
Classes | |
struct | anonymous_namespace{socket_connection.cc}::FreeAddrInfoDeleter |
class | Channel_info_local_socket |
This class abstracts the info. More... | |
class | Channel_info_tcpip_socket |
This class abstracts the info. More... | |
class | TCP_socket |
TCP_socket class represents the TCP sockets abstraction. More... | |
class | Unix_socket |
The Unix_socket class represents an abstraction for creating a unix socket ready to listen for new connections from clients. More... | |
Namespaces | |
namespace | anonymous_namespace{socket_connection.cc} |
Typedefs | |
using | anonymous_namespace{socket_connection.cc}::AddrInfoPtr = std::unique_ptr< addrinfo, FreeAddrInfoDeleter > |
using | admin_thread_arg_t = std::pair< MYSQL_SOCKET, std::string > |
Functions | |
AddrInfoPtr | anonymous_namespace{socket_connection.cc}::GetAddrInfoPtr (const char *node, const char *service, const addrinfo *hints) |
ulong | get_connection_errors_query_block () |
ulong | get_connection_errors_accept () |
ulong | get_connection_errors_tcpwrap () |
static bool | accept_connection (MYSQL_SOCKET listen_sock, MYSQL_SOCKET *connect_sock) |
Accept a new connection on a ready listening socket. More... | |
static void | init_psi_keys (void) |
static void | mark_admin_thread_started () |
Signal to a spawning thread that spawned thread has been started. More... | |
static void | wait_for_admin_thread_started () |
Wait until admin thread has started execution. More... | |
static bool | handle_admin_socket (MYSQL_SOCKET admin_socket, const std::string &network_namespace_for_listening_socket) |
Listen to admin interface and accept incoming connection on it. More... | |
void * | admin_socket_thread (void *arg) |
Initialize thread's internal structures, run thread loop, deinitialize thread's internal structure on thread exit. More... | |
static void | initialize_thread_context () |
Initialize context required for running a thread handling connection requests on admin interface. More... | |
static bool | spawn_admin_thread (MYSQL_SOCKET admin_socket, const std::string &network_namespace) |
Spawn a thread for handling incoming connections request on admin interface. More... | |
Variables | |
static constexpr const uint | MAX_ACCEPT_RETRY {10} |
static std::atomic< ulong > | connection_errors_query_block {0} |
Number of connection errors when selecting on the listening port. More... | |
static std::atomic< ulong > | connection_errors_accept {0} |
Number of connection errors when accepting sockets in the listening port. More... | |
static std::atomic< ulong > | connection_errors_tcpwrap {0} |
Number of connection errors from TCP wrappers. More... | |
const char * | MY_BIND_ALL_ADDRESSES = "*" |
MY_BIND_ALL_ADDRESSES defines a special value for the bind-address option, which means that the server should listen to all available network addresses, both IPv6 (if available) and IPv4. More... | |
const char * | ipv4_all_addresses = "0.0.0.0" |
const char * | ipv6_all_addresses = "::" |
static my_thread_handle | admin_socket_thread_id |
static my_thread_attr_t | admin_socket_thread_attrib |
static bool | admin_thread_started = false |
static mysql_mutex_t | LOCK_start_admin_thread |
static mysql_cond_t | COND_start_admin_thread |
static PSI_mutex_key | key_LOCK_start_admin_thread |
static PSI_cond_key | key_COND_start_admin_thread |
static PSI_mutex_info | admin_socket_thread_mutexes [] |
static PSI_cond_info | admin_socket_thread_conds [] |
using admin_thread_arg_t = std::pair<MYSQL_SOCKET, std::string> |
|
static |
Accept a new connection on a ready listening socket.
listen_sock | Listening socket ready to accept a new connection | |
[out] | connect_sock | Socket corresponding to a new accepted connection |
true | on error |
false | on success |
void * admin_socket_thread | ( | void * | arg | ) |
Initialize thread's internal structures, run thread loop, deinitialize thread's internal structure on thread exit.
arg | pointer to a socket for listening to admin interface |
ulong get_connection_errors_accept | ( | ) |
ulong get_connection_errors_query_block | ( | ) |
ulong get_connection_errors_tcpwrap | ( | ) |
|
static |
Listen to admin interface and accept incoming connection on it.
This function is run in a separate thread.
admin_socket | pointer to a socket for listening to admin interface |
network_namespace_for_listening_socket | network namespace associated with the socket |
|
inlinestatic |
|
inlinestatic |
Initialize context required for running a thread handling connection requests on admin interface.
Such context include mutex LOCK_start_admin_thread, condition variable COND_start_admin_thread and attributes used for thread spawning.
|
inlinestatic |
Signal to a spawning thread that spawned thread has been started.
|
inlinestatic |
Spawn a thread for handling incoming connections request on admin interface.
admin_socket | A socket to listen corresponding admin interface. |
network_namespace | Network namespace to use for communicating via admin socket |
|
inlinestatic |
Wait until admin thread has started execution.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Number of connection errors when accepting sockets in the listening port.
|
static |
Number of connection errors when selecting on the listening port.
|
static |
Number of connection errors from TCP wrappers.
const char* ipv4_all_addresses = "0.0.0.0" |
const char* ipv6_all_addresses = "::" |
|
static |
|
static |
|
static |
|
staticconstexpr |
const char* MY_BIND_ALL_ADDRESSES = "*" |
MY_BIND_ALL_ADDRESSES defines a special value for the bind-address option, which means that the server should listen to all available network addresses, both IPv6 (if available) and IPv4.
Basically, this value instructs the server to make an attempt to bind the server socket to '::' address, and rollback to '0.0.0.0' if the attempt fails.