MySQL 8.0.39
Source Code Documentation
Mysqld_socket_listener Class Reference

This class represents the Mysqld_socket_listener which prepares the listener sockets to receive connection events from the client. More...

#include <socket_connection.h>

Classes

struct  poll_info_t
 

Public Member Functions

 Mysqld_socket_listener (const std::list< Bind_address_info > &bind_addresses, uint tcp_port, const Bind_address_info &admin_bind_addr, uint admin_tcp_port, bool use_separate_thread_for_admin, uint backlog, uint port_timeout, std::string unix_sockname)
 Constructor to setup a listener for listen to connect events from clients. More...
 
bool setup_listener ()
 Set up a listener - set of sockets to listen for connection events from clients. More...
 
Channel_infolisten_for_connection_event ()
 The body of the event loop that listen for connection events from clients. More...
 
void close_listener ()
 Close the listener. More...
 
 ~Mysqld_socket_listener ()
 
bool check_and_spawn_admin_connection_handler_thread () const
 Spawn admin connection handler thread if separate thread is required to accept admin connections. More...
 

Private Member Functions

void add_socket_to_listener (MYSQL_SOCKET listen_socket)
 Add a socket to a set of sockets being waiting for a new connection request. More...
 
const Listen_socketget_listen_socket () const
 Get a socket ready to accept incoming connection. More...
 
void setup_connection_events (const socket_vector_t &socket_vector)
 Set up connection events for poll or select. More...
 

Private Attributes

std::list< Bind_address_infom_bind_addresses
 
Bind_address_info m_admin_bind_address
 
uint m_tcp_port
 
uint m_admin_tcp_port
 
bool m_use_separate_thread_for_admin
 
uint m_backlog
 
uint m_port_timeout
 
std::string m_unix_sockname
 
bool m_unlink_sockname
 
socket_vector_t m_socket_vector
 
MYSQL_SOCKET m_admin_interface_listen_socket
 
poll_info_t m_poll_info
 

Detailed Description

This class represents the Mysqld_socket_listener which prepares the listener sockets to receive connection events from the client.

The Mysqld_socket_listener may be composed of either or both a tcp socket which listens on a default mysqld tcp port or a user specified port via mysqld command-line and a unix socket which is bound to a mysqld default pathname.

Constructor & Destructor Documentation

◆ Mysqld_socket_listener()

Mysqld_socket_listener::Mysqld_socket_listener ( const std::list< Bind_address_info > &  bind_addresses,
uint  tcp_port,
const Bind_address_info admin_bind_addr,
uint  admin_tcp_port,
bool  use_separate_thread_for_admin,
uint  backlog,
uint  port_timeout,
std::string  unix_sockname 
)

Constructor to setup a listener for listen to connect events from clients.

Parameters
bind_addresseslist of addresses to listen to
tcp_portTCP port to bind to
admin_bind_addraddress to listen admin connection
admin_tcp_portTCP port for admin connection to bind
use_separate_thread_for_adminListen to connection requests on admin interface in a separate thread
backlogbacklog specifying length of pending connection queue used in listen.
port_timeoutportname.
unix_socknamepathname for unix socket to bind to

◆ ~Mysqld_socket_listener()

Mysqld_socket_listener::~Mysqld_socket_listener ( )
inline

Member Function Documentation

◆ add_socket_to_listener()

void Mysqld_socket_listener::add_socket_to_listener ( MYSQL_SOCKET  listen_socket)
private

Add a socket to a set of sockets being waiting for a new connection request.

Parameters
listen_socketSocket to listen for.

◆ check_and_spawn_admin_connection_handler_thread()

bool Mysqld_socket_listener::check_and_spawn_admin_connection_handler_thread ( ) const

Spawn admin connection handler thread if separate thread is required to accept admin connections.

Returns
true unable to spawn admin connect handler thread else false

◆ close_listener()

void Mysqld_socket_listener::close_listener ( )

Close the listener.

In case a server is started with the option use_separate_thread_for_admin=true this method also shutdowns a thread for handling of incoming connection requests on admin interface and joins it.

◆ get_listen_socket()

const Listen_socket * Mysqld_socket_listener::get_listen_socket ( ) const
private

Get a socket ready to accept incoming connection.

Returns
A socket ready to accept a new incoming connection.

◆ listen_for_connection_event()

Channel_info * Mysqld_socket_listener::listen_for_connection_event ( )

The body of the event loop that listen for connection events from clients.

Return values
Channel_infoChannel_info object abstracting the connected client details for processing this connection.

◆ setup_connection_events()

void Mysqld_socket_listener::setup_connection_events ( const socket_vector_t socket_vector)
private

Set up connection events for poll or select.

Parameters
socket_vectorsockets to listen for connection requests.

◆ setup_listener()

bool Mysqld_socket_listener::setup_listener ( )

Set up a listener - set of sockets to listen for connection events from clients.

In case a server is started with the option use_separate_thread_for_admin=true invocation of this method also spawns a thread to handle incoming connection requests on admin interface.

Return values
falselistener sockets setup to be used to listen for connect events true failure in setting up the listener.

Member Data Documentation

◆ m_admin_bind_address

Bind_address_info Mysqld_socket_listener::m_admin_bind_address
private

◆ m_admin_interface_listen_socket

MYSQL_SOCKET Mysqld_socket_listener::m_admin_interface_listen_socket
private

◆ m_admin_tcp_port

uint Mysqld_socket_listener::m_admin_tcp_port
private

◆ m_backlog

uint Mysqld_socket_listener::m_backlog
private

◆ m_bind_addresses

std::list<Bind_address_info> Mysqld_socket_listener::m_bind_addresses
private

◆ m_poll_info

poll_info_t Mysqld_socket_listener::m_poll_info
private

◆ m_port_timeout

uint Mysqld_socket_listener::m_port_timeout
private

◆ m_socket_vector

socket_vector_t Mysqld_socket_listener::m_socket_vector
private

◆ m_tcp_port

uint Mysqld_socket_listener::m_tcp_port
private

◆ m_unix_sockname

std::string Mysqld_socket_listener::m_unix_sockname
private

◆ m_unlink_sockname

bool Mysqld_socket_listener::m_unlink_sockname
private

◆ m_use_separate_thread_for_admin

bool Mysqld_socket_listener::m_use_separate_thread_for_admin
private

The documentation for this class was generated from the following files: