MySQL  8.0.27
Source Code Documentation
shared_memory_connection.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013, 2021, Oracle and/or its affiliates.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
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 
25 #ifndef SHARED_MEMORY_CONNECTION_INCLUDED
26 #define SHARED_MEMORY_CONNECTION_INCLUDED
27 
28 #include <Windows.h>
29 #include <string>
30 
31 class Channel_info;
32 class THD;
33 
34 /**
35  This class abstract a shared memory listener to listen for connection
36  events that connect via the shared memory.
37 */
39  std::string m_shared_mem_name;
45  SECURITY_ATTRIBUTES *m_sa_event;
46  SECURITY_ATTRIBUTES *m_sa_mapping;
47  SECURITY_ATTRIBUTES *m_sa_mutex;
49  char *m_suffix_pos;
51 
55  HANDLE m_event_client_read; // for transfer data server <-> client
59 
60  void close_shared_mem();
61 
62  public:
63  /**
64  Constructor to create shared memory listener.
65 
66  @param shared_memory_base_name pointer to shared memory base name.
67  */
71  m_connect_map(0),
75  m_sa_event(0),
76  m_sa_mapping(0),
77  m_sa_mutex(0),
78  m_temp_buffer(0),
87 
88  /**
89  Set up a listener.
90 
91  @retval false listener listener has been setup successfully to listen for
92  connect events true failure in setting up the listener.
93  */
94  bool setup_listener();
95 
96  /**
97  The body of the event loop that listen for connection events from clients.
98 
99  @retval Channel_info Channel_info object abstracting the connected client
100  details for processing this connection.
101  */
103 
104  /**
105  Spawn admin connection handler thread if separate thread is required to
106  accept admin connections. Currently we do not support
107  shared memory admin connections.
108  Hence this method is noop.
109 
110  TODO: Implement for supporting admin connections via shared memory channel.
111 
112  @return false as the method is a NOOP.
113  */
114  bool check_and_spawn_admin_connection_handler_thread() const { return false; }
115 
116  /**
117  Close the listener.
118  */
119  void close_listener();
120 };
121 
122 #endif // SHARED_MEMORY_CONNECTION_INCLUDED
This abstract base class represents connection channel information about a new connection.
Definition: channel_info.h:46
This class abstract a shared memory listener to listen for connection events that connect via the sha...
Definition: shared_memory_connection.h:38
HANDLE m_connect_named_mutex
Definition: shared_memory_connection.h:42
std::string m_shared_mem_name
Definition: shared_memory_connection.h:39
SECURITY_ATTRIBUTES * m_sa_mutex
Definition: shared_memory_connection.h:47
HANDLE m_event_conn_closed
Definition: shared_memory_connection.h:58
char * m_temp_buffer
Definition: shared_memory_connection.h:50
int m_connect_number
Definition: shared_memory_connection.h:48
char * m_suffix_pos
Definition: shared_memory_connection.h:49
Channel_info * listen_for_connection_event()
The body of the event loop that listen for connection events from clients.
Definition: shared_memory_connection.cc:214
HANDLE m_handle_client_file_map
Definition: shared_memory_connection.h:52
bool setup_listener()
Set up a listener.
Definition: shared_memory_connection.cc:135
HANDLE m_event_server_read
Definition: shared_memory_connection.h:57
char * m_connect_map
Definition: shared_memory_connection.h:41
HANDLE m_connect_file_map
Definition: shared_memory_connection.h:40
void close_listener()
Close the listener.
Definition: shared_memory_connection.cc:323
SECURITY_ATTRIBUTES * m_sa_mapping
Definition: shared_memory_connection.h:46
bool check_and_spawn_admin_connection_handler_thread() const
Spawn admin connection handler thread if separate thread is required to accept admin connections.
Definition: shared_memory_connection.h:114
HANDLE m_event_connect_request
Definition: shared_memory_connection.h:43
void close_shared_mem()
Definition: shared_memory_connection.cc:122
char * m_handle_client_map
Definition: shared_memory_connection.h:53
HANDLE m_event_client_wrote
Definition: shared_memory_connection.h:54
HANDLE m_event_client_read
Definition: shared_memory_connection.h:55
Shared_mem_listener(const std::string *shared_memory_base_name)
Constructor to create shared memory listener.
Definition: shared_memory_connection.h:68
HANDLE m_event_connect_answer
Definition: shared_memory_connection.h:44
HANDLE m_event_server_wrote
Definition: shared_memory_connection.h:56
SECURITY_ATTRIBUTES * m_sa_event
Definition: shared_memory_connection.h:45
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
static char * shared_memory_base_name
Definition: mysqltest.cc:191
#define NULL
Definition: types.h:54
#define HANDLE
Definition: violite.h:158