MySQL 9.3.0
Source Code Documentation
failed_attempts_list_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef CONNECTION_CONTROL_FAILED_ATTEMPTS_LIST_IMP_H
25#define CONNECTION_CONTROL_FAILED_ATTEMPTS_LIST_IMP_H
26
27#include <map>
28#include <shared_mutex>
29#include "connection_control.h"
31
32namespace connection_control {
34 public:
35 void failed_attempts_define(const char *userhost);
36 bool failed_attempts_undefine(const char *userhost);
37
38 /**
39 Fetch a copy of the queue data to return to a PFS table
40 @retval the data to put in the PFS table
41 */
43 unsigned long long get_failed_attempts_list_count();
44 unsigned long long get_failed_attempts_count(const char *userhost);
45 void reset();
46
47 private:
48 //* A case insensitive comparator using the C library */
49 struct ciLessLibC {
50 bool operator()(const std::string &lhs, const std::string &rhs) const {
51#if defined _WIN32
52 return _stricmp(lhs.c_str(), rhs.c_str()) < 0;
53#else
54 return strcasecmp(lhs.c_str(), rhs.c_str()) < 0;
55#endif
56 }
57 };
58 std::map<std::string, PSI_ulong, ciLessLibC> failed_attempts_map;
61};
62} // namespace connection_control
64
65#endif /* CONNECTION_CONTROL_FAILED_ATTEMPTS_LIST_IMP_H */
Definition: connection_control_memory.h:41
Definition: failed_attempts_list_imp.h:33
unsigned long long get_failed_attempts_list_count()
Definition: connection_control_pfs_table.cc:73
void reset()
Definition: connection_control_pfs_table.cc:88
bool failed_attempts_undefine(const char *userhost)
Definition: connection_control_pfs_table.cc:53
Connection_control_pfs_table_data * copy_pfs_table_data()
Fetch a copy of the queue data to return to a PFS table.
Definition: connection_control_pfs_table.cc:59
void failed_attempts_define(const char *userhost)
Definition: connection_control_pfs_table.cc:40
std::shared_mutex LOCK_shared_failed_attempts_list
Definition: failed_attempts_list_imp.h:60
unsigned long long get_failed_attempts_count(const char *userhost)
Definition: connection_control_pfs_table.cc:78
std::map< std::string, PSI_ulong, ciLessLibC > failed_attempts_map
Definition: failed_attempts_list_imp.h:58
std::mutex LOCK_failed_attempts_list
Definition: failed_attempts_list_imp.h:59
connection_control::Failed_attempts_list_imp g_failed_attempts_list
Definition: connection_control.cc:50
Definition: connection_control.h:70
std::vector< Connection_control_pfs_table_data_row, CustomAllocator< Connection_control_pfs_table_data_row > > Connection_control_pfs_table_data
Definition: connection_control_pfs_table.h:79
Definition: failed_attempts_list_imp.h:49
bool operator()(const std::string &lhs, const std::string &rhs) const
Definition: failed_attempts_list_imp.h:50