Debian Codegraph @

upstream/debian-unstable/man3/BIO_should_retry.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "BIO_SHOULD_RETRY 3SSL"
58 .TH BIO_SHOULD_RETRY 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 BIO_should_read, BIO_should_write,
65 BIO_should_io_special, BIO_retry_type, BIO_should_retry,
66 BIO_get_retry_BIO, BIO_get_retry_reason, BIO_set_retry_reason \- BIO retry
67 functions
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& #include <openssl/bio.h>
72 \&
73 \& int BIO_should_read(BIO *b);
74 \& int BIO_should_write(BIO *b);
75 \& int BIO_should_io_special(iBIO *b);
76 \& int BIO_retry_type(BIO *b);
77 \& int BIO_should_retry(BIO *b);
78 \&
79 \& BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
80 \& int BIO_get_retry_reason(BIO *bio);
81 \& void BIO_set_retry_reason(BIO *bio, int reason);
82 .Ve
83 .SH DESCRIPTION
84 .IX Header "DESCRIPTION"
85 These functions determine why a BIO is not able to read or write data.
86 They will typically be called after a failed \fBBIO_read_ex()\fR or \fBBIO_write_ex()\fR
87 call.
88 .PP
89 \&\fBBIO_should_retry()\fR is true if the call that produced this condition
90 should then be retried at a later time.
91 .PP
92 If \fBBIO_should_retry()\fR is false then the cause is an error condition.
93 .PP
94 \&\fBBIO_should_read()\fR is true if the cause of the condition is that the BIO
95 has insufficient data to return. Check for readability and/or retry the
96 last operation.
97 .PP
98 \&\fBBIO_should_write()\fR is true if the cause of the condition is that the BIO
99 has pending data to write. Check for writability and/or retry the
100 last operation.
101 .PP
102 \&\fBBIO_should_io_special()\fR is true if some "special" condition, that is a
103 reason other than reading or writing is the cause of the condition.
104 .PP
105 \&\fBBIO_retry_type()\fR returns a mask of the cause of a retry condition
106 consisting of the values \fBBIO_FLAGS_READ\fR, \fBBIO_FLAGS_WRITE\fR,
107 \&\fBBIO_FLAGS_IO_SPECIAL\fR though current BIO types will only set one of
108 these.
109 .PP
110 \&\fBBIO_get_retry_BIO()\fR determines the precise reason for the special
111 condition, it returns the BIO that caused this condition and if
112 \&\fBreason\fR is not NULL it contains the reason code. The meaning of
113 the reason code and the action that should be taken depends on
114 the type of BIO that resulted in this condition.
115 .PP
116 \&\fBBIO_get_retry_reason()\fR returns the reason for a special condition if
117 passed the relevant BIO, for example as returned by \fBBIO_get_retry_BIO()\fR.
118 .PP
119 \&\fBBIO_set_retry_reason()\fR sets the retry reason for a special condition for a given
120 BIO. This would usually only be called by BIO implementations.
121 .SH NOTES
122 .IX Header "NOTES"
123 \&\fBBIO_should_read()\fR, \fBBIO_should_write()\fR, \fBBIO_should_io_special()\fR,
124 \&\fBBIO_retry_type()\fR, and \fBBIO_should_retry()\fR, are implemented as macros.
125 .PP
126 If \fBBIO_should_retry()\fR returns false then the precise "error condition"
127 depends on the BIO type that caused it and the return code of the BIO
128 operation. For example if a call to \fBBIO_read_ex()\fR on a socket BIO returns
129 0 and \fBBIO_should_retry()\fR is false then the cause will be that the
130 connection closed. A similar condition on a file BIO will mean that it
131 has reached EOF. Some BIO types may place additional information on
132 the error queue. For more details see the individual BIO type manual
133 pages.
134 .PP
135 If the underlying I/O structure is in a blocking mode almost all current
136 BIO types will not request a retry, because the underlying I/O
137 calls will not. If the application knows that the BIO type will never
138 signal a retry then it need not call \fBBIO_should_retry()\fR after a failed
139 BIO I/O call. This is typically done with file BIOs.
140 .PP
141 SSL BIOs are the only current exception to this rule: they can request a
142 retry even if the underlying I/O structure is blocking, if a handshake
143 occurs during a call to \fBBIO_read()\fR. An application can retry the failed
144 call immediately or avoid this situation by setting SSL_MODE_AUTO_RETRY
145 on the underlying SSL structure.
146 .PP
147 While an application may retry a failed non blocking call immediately
148 this is likely to be very inefficient because the call will fail
149 repeatedly until data can be processed or is available. An application
150 will normally wait until the necessary condition is satisfied. How
151 this is done depends on the underlying I/O structure.
152 .PP
153 For example if the cause is ultimately a socket and \fBBIO_should_read()\fR
154 is true then a call to \fBselect()\fR may be made to wait until data is
155 available and then retry the BIO operation. By combining the retry
156 conditions of several non blocking BIOs in a single \fBselect()\fR call
157 it is possible to service several BIOs in a single thread, though
158 the performance may be poor if SSL BIOs are present because long delays
159 can occur during the initial handshake process.
160 .PP
161 It is possible for a BIO to block indefinitely if the underlying I/O
162 structure cannot process or return any data. This depends on the behaviour of
163 the platforms I/O functions. This is often not desirable: one solution
164 is to use non blocking I/O and use a timeout on the \fBselect()\fR (or
165 equivalent) call.
166 .SH BUGS
167 .IX Header "BUGS"
168 The OpenSSL ASN1 functions cannot gracefully deal with non blocking I/O:
169 that is they cannot retry after a partial read or write. This is usually
170 worked around by only passing the relevant data to ASN1 functions when
171 the entire structure can be read or written.
172 .SH "RETURN VALUES"
173 .IX Header "RETURN VALUES"
174 \&\fBBIO_should_read()\fR, \fBBIO_should_write()\fR, \fBBIO_should_io_special()\fR, and
175 \&\fBBIO_should_retry()\fR return either 1 or 0 based on the actual conditions
176 of the \fBBIO\fR.
177 .PP
178 \&\fBBIO_retry_type()\fR returns a flag combination presenting the cause of a retry
179 condition or false if there is no retry condition.
180 .PP
181 \&\fBBIO_get_retry_BIO()\fR returns a valid \fBBIO\fR structure.
182 .PP
183 \&\fBBIO_get_retry_reason()\fR returns the reason for a special condition.
184 .SH "SEE ALSO"
185 .IX Header "SEE ALSO"
186 \&\fBbio\fR\|(7)
187 .SH HISTORY
188 .IX Header "HISTORY"
189 The \fBBIO_get_retry_reason()\fR and \fBBIO_set_retry_reason()\fR functions were added in
190 OpenSSL 1.1.0.
191 .SH COPYRIGHT
192 .IX Header "COPYRIGHT"
193 Copyright 2000\-2018 The OpenSSL Project Authors. All Rights Reserved.
194 .PP
195 Licensed under the Apache License 2.0 (the "License"). You may not use
196 this file except in compliance with the License. You can obtain a copy
197 in the file LICENSE in the source distribution or at
198 <https://www.openssl.org/source/license.html>.