MySQL  8.0.26
Source Code Documentation
node_connection.h
Go to the documentation of this file.
1 /* Copyright (c) 2012, 2021, 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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef NODE_CONNECTION_H
24 #define NODE_CONNECTION_H
25 
26 #include <stdlib.h>
27 
28 #ifndef XCOM_WITHOUT_OPENSSL
29 #ifdef _WIN32
30 /* In OpenSSL before 1.1.0, we need this first. */
31 #include <winsock2.h>
32 #endif
33 
34 #include <openssl/ssl.h>
35 
36 #endif
37 
38 #include "xcom/xcom_proto.h"
39 #include "xdr_gen/xcom_vp.h"
40 
42 typedef enum con_state con_state;
43 
45  int fd;
46 #ifndef XCOM_WITHOUT_OPENSSL
47  SSL *ssl_fd;
48 #endif
50  unsigned int snd_tag;
51  xcom_proto x_proto;
52 };
53 
55 
56 #ifndef XCOM_WITHOUT_OPENSSL
57 static inline connection_descriptor *new_connection(int fd, SSL *ssl_fd) {
59  (connection_descriptor *)calloc((size_t)1, sizeof(connection_descriptor));
60  c->fd = fd;
61  c->ssl_fd = ssl_fd;
62  c->connected_ = CON_NULL;
63  return c;
64 }
65 #else
66 static inline connection_descriptor *new_connection(int fd) {
68  (connection_descriptor *)calloc((size_t)1, sizeof(connection_descriptor));
69  c->fd = fd;
70  c->connected_ = CON_NULL;
71  return c;
72 }
73 #endif
74 static inline int is_connected(connection_descriptor *con) {
75  return con->connected_ >= CON_FD;
76 }
77 
78 static inline int proto_done(connection_descriptor *con) {
79  return con->connected_ == CON_PROTO;
80 }
81 
82 static inline void set_connected(connection_descriptor *con, con_state val) {
83  con->connected_ = val;
84 }
85 
86 #endif /* NODE_CONNECTION_H */
static connection_descriptor * new_connection(int fd, SSL *ssl_fd)
Definition: node_connection.h:57
con_state
Definition: node_connection.h:41
@ CON_NULL
Definition: node_connection.h:41
@ CON_PROTO
Definition: node_connection.h:41
@ CON_FD
Definition: node_connection.h:41
static void set_connected(connection_descriptor *con, con_state val)
Definition: node_connection.h:82
static int proto_done(connection_descriptor *con)
Definition: node_connection.h:78
struct connection_descriptor connection_descriptor
Definition: node_connection.h:54
static int is_connected(connection_descriptor *con)
Definition: node_connection.h:74
Definition: node_connection.h:44
xcom_proto x_proto
Definition: node_connection.h:51
con_state connected_
Definition: node_connection.h:49
int fd
Definition: node_connection.h:45
SSL * ssl_fd
Definition: node_connection.h:47
unsigned int snd_tag
Definition: node_connection.h:50