MySQL  8.0.20
Source Code Documentation
retry.h
Go to the documentation of this file.
1 /* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
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 RETRY_H
24 #define RETRY_H
25 
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifndef XCOM_WITHOUT_OPENSSL
34 
35 static inline int can_retry(int err) {
36  if (is_ssl_err(err))
37  return from_ssl_err(err) == SSL_ERROR_WANT_WRITE ||
38  from_ssl_err(err) == SSL_ERROR_WANT_READ;
39  else
40  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
42 }
43 
44 static inline int can_retry_read(int err) {
45  if (is_ssl_err(err))
46  return from_ssl_err(err) == SSL_ERROR_WANT_READ;
47  else
48  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
50 }
51 
52 static inline int can_retry_write(int err) {
53  if (is_ssl_err(err))
54  return from_ssl_err(err) == SSL_ERROR_WANT_WRITE;
55  else
56  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
58 }
59 #else
60 static inline int can_retry(int err) {
61  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
63 }
64 
65 static inline int can_retry_read(int err) {
66  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
68 }
69 
70 static inline int can_retry_write(int err) {
71  return from_errno(err) == SOCK_EAGAIN || from_errno(err) == SOCK_EINTR ||
73 }
74 #endif
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
#define SOCK_EWOULDBLOCK
Definition: task_os.h:92
static int from_ssl_err(int err)
Definition: result.h:47
static int can_retry_read(int err)
Definition: retry.h:44
#define SOCK_EAGAIN
Definition: task_os.h:91
static int can_retry_write(int err)
Definition: retry.h:52
static int is_ssl_err(int err)
Definition: result.h:49
#define SOCK_EINTR
Definition: task_os.h:90
static int can_retry(int err)
Definition: retry.h:35
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:908
static int from_errno(int err)
Definition: result.h:45