MySQL 8.0.39
Source Code Documentation
retry.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 2024, 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 RETRY_H
25#define RETRY_H
26
27#include "xcom/result.h"
28#include "xcom/task_debug.h"
29#include "xcom/task_os.h"
30
31#ifndef XCOM_WITHOUT_OPENSSL
32
33static inline int can_retry(int err) {
34 if (is_ssl_err(err))
35 return from_ssl_err(err) == SSL_ERROR_WANT_WRITE ||
36 from_ssl_err(err) == SSL_ERROR_WANT_READ;
37 else
40}
41
42static inline int can_retry_read(int err) {
43 if (is_ssl_err(err))
44 return from_ssl_err(err) == SSL_ERROR_WANT_READ;
45 else
48}
49
50static inline int can_retry_write(int err) {
51 if (is_ssl_err(err))
52 return from_ssl_err(err) == SSL_ERROR_WANT_WRITE;
53 else
56}
57#else
58static inline int can_retry(int err) {
59 int retval = from_errno(err) == SOCK_EAGAIN ||
62 if (!retval) IFDBG(D_NONE, FN; STRLIT("cannot retry "); NDBG(err, d));
63 return retval;
64}
65
66static inline int can_retry_read(int err) {
67 int retval = from_errno(err) == SOCK_EAGAIN ||
70 if (!retval) IFDBG(D_NONE, FN; STRLIT("cannot retry "); NDBG(err, d));
71 return retval;
72}
73
74static inline int can_retry_write(int err) {
75 int retval = from_errno(err) == SOCK_EAGAIN ||
78 if (!retval) IFDBG(D_NONE, FN; STRLIT("cannot retry "); NDBG(err, d));
79 return retval;
80}
81#endif
82
83#endif
#define IFDBG(mask, body)
Definition: gcs_debug.h:279
#define FN
Definition: gcs_debug.h:308
@ D_NONE
Definition: gcs_debug.h:174
#define STRLIT(x)
Definition: gcs_debug.h:316
#define NDBG(x, f)
Definition: gcs_debug.h:318
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:910
static int is_ssl_err(int err)
Definition: result.h:46
static int from_ssl_err(int err)
Definition: result.h:44
static int from_errno(int err)
Definition: result.h:42
static int can_retry_write(int err)
Definition: retry.h:50
static int can_retry(int err)
Definition: retry.h:33
static int can_retry_read(int err)
Definition: retry.h:42
#define SOCK_EWOULDBLOCK
Definition: task_os.h:92
#define SOCK_EAGAIN
Definition: task_os.h:91
#define SOCK_EINTR
Definition: task_os.h:90