MySQL 9.3.0
Source Code Documentation
connection_control::Connection_delay_action Class Reference

Connection event action to enforce max failed login constraint. More...

#include <connection_delay.h>

Inheritance diagram for connection_control::Connection_delay_action:
[legend]

Public Member Functions

 Connection_delay_action (int64 threshold, int64 min_delay, int64 max_delay, opt_connection_control *sys_vars, size_t sys_vars_size, stats_connection_control *status_vars, size_t status_vars_size, mysql_rwlock_t *lock)
 Connection_delay_action Constructor. More...
 
 ~Connection_delay_action () override
 Destructor. More...
 
void init (Connection_event_coordinator *coordinator)
 Subscribe with coordinator for connection events. More...
 
void set_threshold (int64 threshold)
 Set threshold value. More...
 
int64 get_threshold () const
 Get threshold value. More...
 
bool set_delay (int64 new_value, bool min)
 Set min/max delay. More...
 
int64 get_max_delay () const
 Get max value. More...
 
int64 get_min_delay () const
 Get min value. More...
 
bool notify_event (MYSQL_THD thd, Connection_event_coordinator *coordinator, const mysql_event_tracking_connection_data *connection_event) override
 Overridden functions. More...
 
bool notify_sys_var (Connection_event_coordinator *coordinator, opt_connection_control variable, void *new_value) override
 Notification of a change in system variable value. More...
 
- Public Member Functions inherited from connection_control::Connection_event_observer
virtual ~Connection_event_observer ()=default
 

Private Member Functions

void deinit ()
 Clear data from Connection_delay_action. More...
 
void make_hash_key (MYSQL_THD thd, Sql_string &s)
 Create hash key of the format 'user'@'host'. More...
 
ulonglong get_wait_time (int64 count)
 Generates wait time. More...
 
void conditional_wait (ulonglong wait_time)
 Wait till the wait_time expires or thread is killed. More...
 

Private Attributes

int64 m_threshold
 Threshold value which triggers wait. More...
 
int64 m_min_delay
 Lower cap on delay in msec to be generated. More...
 
int64 m_max_delay
 Upper cap on delay in msec to be generated. More...
 
std::vector< opt_connection_control, CustomAllocator< opt_connection_control > > m_sys_vars
 System variables. More...
 
std::vector< stats_connection_control, CustomAllocator< stats_connection_control > > m_stats_vars
 Status variables. More...
 
mysql_rwlock_tm_lock
 RW lock. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from connection_control::Connection_control_alloc
static void * operator new (size_t size) noexcept
 
static void * operator new[] (size_t size) noexcept
 
static void operator delete (void *ptr)
 
static void operator delete[] (void *ptr)
 

Detailed Description

Connection event action to enforce max failed login constraint.

Constructor & Destructor Documentation

◆ Connection_delay_action()

connection_control::Connection_delay_action::Connection_delay_action ( int64  threshold,
int64  min_delay,
int64  max_delay,
opt_connection_control sys_vars,
size_t  sys_vars_size,
stats_connection_control status_vars,
size_t  status_vars_size,
mysql_rwlock_t lock 
)

Connection_delay_action Constructor.

Parameters
[in]thresholdDefines a threshold after which wait is triggered
[in]min_delayLower cap on wait
[in]max_delayUpper cap on wait
[in]sys_varsSystem variables
[in]sys_vars_sizeSize of sys_vars array
[in]status_varsStatus variables
[in]status_vars_sizeSize of status_vars array
[in]lockRW lock handle

◆ ~Connection_delay_action()

connection_control::Connection_delay_action::~Connection_delay_action ( )
inlineoverride

Destructor.

Member Function Documentation

◆ conditional_wait()

void connection_control::Connection_delay_action::conditional_wait ( ulonglong  wait_time)
private

Wait till the wait_time expires or thread is killed.

Parameters
[in]wait_timeMaximum time to wait in msec

mysql_cond_timedwait requires wait time in timespec format

Initialize mutex required for mysql_cond_timedwait

Register wait condition with THD

◆ deinit()

void connection_control::Connection_delay_action::deinit ( )
private

Clear data from Connection_delay_action.

◆ get_max_delay()

int64 connection_control::Connection_delay_action::get_max_delay ( ) const
inline

Get max value.

◆ get_min_delay()

int64 connection_control::Connection_delay_action::get_min_delay ( ) const
inline

Get min value.

◆ get_threshold()

int64 connection_control::Connection_delay_action::get_threshold ( ) const
inline

Get threshold value.

◆ get_wait_time()

ulonglong connection_control::Connection_delay_action::get_wait_time ( int64  count)
inlineprivate

Generates wait time.

Parameters
count[in] Proposed delay in msec
Returns
wait time

◆ init()

void connection_control::Connection_delay_action::init ( Connection_event_coordinator coordinator)

Subscribe with coordinator for connection events.

Parameters
[in]coordinatorHandle to Connection_event_coordinator for registration

◆ make_hash_key()

void connection_control::Connection_delay_action::make_hash_key ( MYSQL_THD  thd,
Sql_string s 
)
private

Create hash key of the format 'user'@'host'.

Policy:

  1. Use proxy_user information if available. Else if,
  2. Use priv_user/priv_host if either of them is not empty. Else,
  3. Use user/host
Parameters
[in]thdTHD pointer for getting security context
[out]sHash key is stored here

◆ notify_event()

bool connection_control::Connection_delay_action::notify_event ( MYSQL_THD  thd,
Connection_event_coordinator coordinator,
const mysql_event_tracking_connection_data connection_event 
)
overridevirtual

Overridden functions.

Handle a connection event and, if required, wait for random amount of time before returning.

We only care about CONNECT and CHANGE_USER sub events.

Parameters
[in]thdTHD pointer
[in]coordinatorConnection_event_coordinator
[in]connection_eventConnection event to be handled
Returns
status of connection event handling
Return values
falseSuccessfully handled an event.
trueSomething went wrong. error_buffer may contain details.

Implements connection_control::Connection_event_observer.

◆ notify_sys_var()

bool connection_control::Connection_delay_action::notify_sys_var ( Connection_event_coordinator coordinator,
opt_connection_control  variable,
void *  new_value 
)
overridevirtual

Notification of a change in system variable value.

Parameters
[in]coordinatorHandle to coordinator
[in]variableEnum of variable
[in]new_valueNew value for variable
Returns
processing status
Return values
falseChange in variable value processed successfully
trueError processing new value. error_buffer may contain more details.

Implements connection_control::Connection_event_observer.

◆ set_delay()

bool connection_control::Connection_delay_action::set_delay ( int64  new_value,
bool  min 
)
inline

Set min/max delay.

Parameters
new_value[in] New m_min_delay/m_max_delay value
min[in] true for m_min_delay. false otherwise.
Returns
whether m_min_delay/m_max_delay value was changed successfully or not
Return values
falseSuccess
trueFailure. Invalid value specified.

◆ set_threshold()

void connection_control::Connection_delay_action::set_threshold ( int64  threshold)
inline

Set threshold value.

Parameters
threshold[in] New threshold value

Member Data Documentation

◆ m_lock

mysql_rwlock_t* connection_control::Connection_delay_action::m_lock
private

RW lock.

◆ m_max_delay

int64 connection_control::Connection_delay_action::m_max_delay
private

Upper cap on delay in msec to be generated.

◆ m_min_delay

int64 connection_control::Connection_delay_action::m_min_delay
private

Lower cap on delay in msec to be generated.

◆ m_stats_vars

std::vector<stats_connection_control, CustomAllocator<stats_connection_control> > connection_control::Connection_delay_action::m_stats_vars
private

Status variables.

◆ m_sys_vars

std::vector<opt_connection_control, CustomAllocator<opt_connection_control> > connection_control::Connection_delay_action::m_sys_vars
private

System variables.

◆ m_threshold

int64 connection_control::Connection_delay_action::m_threshold
private

Threshold value which triggers wait.


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