1BIO_SHOULD_RETRY(3)                 OpenSSL                BIO_SHOULD_RETRY(3)
2
3
4

NAME

6       BIO_should_read, BIO_should_write, BIO_should_io_special,
7       BIO_retry_type, BIO_should_retry, BIO_get_retry_BIO,
8       BIO_get_retry_reason, BIO_set_retry_reason - BIO retry functions
9

SYNOPSIS

11        #include <openssl/bio.h>
12
13        int BIO_should_read(BIO *b);
14        int BIO_should_write(BIO *b);
15        int BIO_should_io_special(iBIO *b);
16        int BIO_retry_type(BIO *b);
17        int BIO_should_retry(BIO *b);
18
19        BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
20        int BIO_get_retry_reason(BIO *bio);
21        void BIO_set_retry_reason(BIO *bio, int reason);
22

DESCRIPTION

24       These functions determine why a BIO is not able to read or write data.
25       They will typically be called after a failed BIO_read_ex() or
26       BIO_write_ex() call.
27
28       BIO_should_retry() is true if the call that produced this condition
29       should then be retried at a later time.
30
31       If BIO_should_retry() is false then the cause is an error condition.
32
33       BIO_should_read() is true if the cause of the condition is that the BIO
34       has insufficient data to return. Check for readability and/or retry the
35       last operation.
36
37       BIO_should_write() is true if the cause of the condition is that the
38       BIO has pending data to write. Check for writability and/or retry the
39       last operation.
40
41       BIO_should_io_special() is true if some "special" condition, that is a
42       reason other than reading or writing is the cause of the condition.
43
44       BIO_retry_type() returns a mask of the cause of a retry condition
45       consisting of the values BIO_FLAGS_READ, BIO_FLAGS_WRITE,
46       BIO_FLAGS_IO_SPECIAL though current BIO types will only set one of
47       these.
48
49       BIO_get_retry_BIO() determines the precise reason for the special
50       condition, it returns the BIO that caused this condition and if reason
51       is not NULL it contains the reason code. The meaning of the reason code
52       and the action that should be taken depends on the type of BIO that
53       resulted in this condition.
54
55       BIO_get_retry_reason() returns the reason for a special condition if
56       passed the relevant BIO, for example as returned by
57       BIO_get_retry_BIO().
58
59       BIO_set_retry_reason() sets the retry reason for a special condition
60       for a given BIO. This would usually only be called by BIO
61       implementations.
62

NOTES

64       BIO_should_read(), BIO_should_write(), BIO_should_io_special(),
65       BIO_retry_type(), and BIO_should_retry(), are implemented as macros.
66
67       If BIO_should_retry() returns false then the precise "error condition"
68       depends on the BIO type that caused it and the return code of the BIO
69       operation. For example if a call to BIO_read_ex() on a socket BIO
70       returns 0 and BIO_should_retry() is false then the cause will be that
71       the connection closed. A similar condition on a file BIO will mean that
72       it has reached EOF. Some BIO types may place additional information on
73       the error queue. For more details see the individual BIO type manual
74       pages.
75
76       If the underlying I/O structure is in a blocking mode almost all
77       current BIO types will not request a retry, because the underlying I/O
78       calls will not. If the application knows that the BIO type will never
79       signal a retry then it need not call BIO_should_retry() after a failed
80       BIO I/O call. This is typically done with file BIOs.
81
82       SSL BIOs are the only current exception to this rule: they can request
83       a retry even if the underlying I/O structure is blocking, if a
84       handshake occurs during a call to BIO_read(). An application can retry
85       the failed call immediately or avoid this situation by setting
86       SSL_MODE_AUTO_RETRY on the underlying SSL structure.
87
88       While an application may retry a failed non blocking call immediately
89       this is likely to be very inefficient because the call will fail
90       repeatedly until data can be processed or is available. An application
91       will normally wait until the necessary condition is satisfied. How this
92       is done depends on the underlying I/O structure.
93
94       For example if the cause is ultimately a socket and BIO_should_read()
95       is true then a call to select() may be made to wait until data is
96       available and then retry the BIO operation. By combining the retry
97       conditions of several non blocking BIOs in a single select() call it is
98       possible to service several BIOs in a single thread, though the
99       performance may be poor if SSL BIOs are present because long delays can
100       occur during the initial handshake process.
101
102       It is possible for a BIO to block indefinitely if the underlying I/O
103       structure cannot process or return any data. This depends on the
104       behaviour of the platforms I/O functions. This is often not desirable:
105       one solution is to use non blocking I/O and use a timeout on the
106       select() (or equivalent) call.
107

BUGS

109       The OpenSSL ASN1 functions cannot gracefully deal with non blocking
110       I/O: that is they cannot retry after a partial read or write. This is
111       usually worked around by only passing the relevant data to ASN1
112       functions when the entire structure can be read or written.
113

RETURN VALUES

115       BIO_should_read(), BIO_should_write(), BIO_should_io_special(), and
116       BIO_should_retry() return either 1 or 0 based on the actual conditions
117       of the BIO.
118
119       BIO_retry_type() returns a flag combination presenting the cause of a
120       retry condition or false if there is no retry condition.
121
122       BIO_get_retry_BIO() returns a valid BIO structure.
123
124       BIO_get_retry_reason() returns the reason for a special condition.
125

SEE ALSO

127       bio
128

HISTORY

130       The BIO_get_retry_reason() and BIO_set_retry_reason() functions were
131       added in OpenSSL 1.1.0.
132
134       Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
135
136       Licensed under the OpenSSL license (the "License").  You may not use
137       this file except in compliance with the License.  You can obtain a copy
138       in the file LICENSE in the source distribution or at
139       <https://www.openssl.org/source/license.html>.
140
141
142
1431.1.1q                            2023-02-06               BIO_SHOULD_RETRY(3)
Impressum