summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BIO_should_retry.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BIO_should_retry.3')
-rw-r--r--src/lib/libcrypto/man/BIO_should_retry.3145
1 files changed, 145 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_should_retry.3 b/src/lib/libcrypto/man/BIO_should_retry.3
new file mode 100644
index 0000000000..cb5eda3121
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_should_retry.3
@@ -0,0 +1,145 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_SHOULD_RETRY 3
3.Os
4.Sh NAME
5.Nm BIO_should_retry ,
6.Nm BIO_should_read ,
7.Nm BIO_should_write ,
8.Nm BIO_should_io_special ,
9.Nm BIO_retry_type ,
10.Nm BIO_get_retry_BIO ,
11.Nm BIO_get_retry_reason
12.Nd BIO retry functions
13.Sh SYNOPSIS
14.In openssl/bio.h
15.Pp
16.Fd #define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
17.Fd #define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
18.Fd #define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
19.Fd #define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
20.Fd #define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
21.Fd #define BIO_FLAGS_READ 0x01
22.Fd #define BIO_FLAGS_WRITE 0x02
23.Fd #define BIO_FLAGS_IO_SPECIAL 0x04
24.Fd #define BIO_FLAGS_RWS \e
25.Fd \& (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
26.Fd #define BIO_FLAGS_SHOULD_RETRY 0x08
27.Ft BIO *
28.Fo BIO_get_retry_BIO
29.Fa "BIO *bio"
30.Fa "int *reason"
31.Fc
32.Ft int
33.Fo BIO_get_retry_reason
34.Fa "BIO *bio"
35.Fc
36.Sh DESCRIPTION
37These functions determine why a BIO is not able to read or write data.
38They will typically be called after a failed
39.Xr BIO_read 3
40or
41.Xr BIO_write 3
42call.
43.Pp
44.Fn BIO_should_retry
45is true if the call that produced this condition
46should be retried at a later time.
47.Pp
48If
49.Fn BIO_should_retry
50is false, the cause is an error condition.
51.Pp
52.Fn BIO_should_read
53is true if the cause of the condition is that a BIO needs to read data.
54.Pp
55.Fn BIO_should_write
56is true if the cause of the condition is that a BIO needs to write data.
57.Pp
58.Fn BIO_should_io_special
59is true if some "special" condition, that is a reason other than
60reading or writing, is the cause of the condition.
61.Pp
62.Fn BIO_retry_type
63returns a mask of the cause of a retry condition consisting of the values
64.Dv BIO_FLAGS_READ ,
65.Dv BIO_FLAGS_WRITE ,
66.Dv BIO_FLAGS_IO_SPECIAL
67though current BIO types will only set one of these.
68.Pp
69.Fn BIO_get_retry_BIO
70determines the precise reason for the special condition.
71It returns the BIO that caused this condition and if
72.Fa reason
73is not
74.Dv NULL
75it contains the reason code.
76The meaning of the reason code and the action that should be taken
77depends on the type of BIO that resulted in this condition.
78.Pp
79.Fn BIO_get_retry_reason
80returns the reason for a special condition
81if passed the relevant BIO, for example as returned by
82.Fn BIO_get_retry_BIO .
83.Sh NOTES
84If
85.Fn BIO_should_retry
86returns false, then the precise "error condition" depends on
87the BIO type that caused it and the return code of the BIO operation.
88For example if a call to
89.Xr BIO_read 3
90on a socket BIO returns 0 and
91.Fn BIO_should_retry
92is false, then the cause will be that the connection closed.
93A similar condition on a file BIO will mean that it has reached EOF.
94Some BIO types may place additional information on the error queue.
95For more details see the individual BIO type manual pages.
96.Pp
97If the underlying I/O structure is in a blocking mode,
98almost all current BIO types will not request a retry,
99because the underlying I/O calls will not.
100If the application knows that the BIO type will never
101signal a retry then it need not call
102.Fn BIO_should_retry
103after a failed BIO I/O call.
104This is typically done with file BIOs.
105.Pp
106SSL BIOs are the only current exception to this rule:
107they can request a retry even if the underlying I/O structure
108is blocking, if a handshake occurs during a call to
109.Xr BIO_read 3 .
110An application can retry the failed call immediately
111or avoid this situation by setting
112.Dv SSL_MODE_AUTO_RETRY
113on the underlying SSL structure.
114.Pp
115While an application may retry a failed non blocking call immediately,
116this is likely to be very inefficient because the call will fail
117repeatedly until data can be processed or is available.
118An application will normally wait until the necessary condition
119is satisfied.
120How this is done depends on the underlying I/O structure.
121.Pp
122For example if the cause is ultimately a socket and
123.Fn BIO_should_read
124is true then a call to
125.Xr select 2
126may be made to wait until data is available
127and then retry the BIO operation.
128By combining the retry conditions of several non blocking BIOs in a single
129.Xr select 2
130call it is possible to service several BIOs in a single thread,
131though the performance may be poor if SSL BIOs are present because
132long delays can occur during the initial handshake process.
133.Pp
134It is possible for a BIO to block indefinitely if the underlying I/O
135structure cannot process or return any data.
136This depends on the behaviour of the platforms I/O functions.
137This is often not desirable: one solution is to use non blocking I/O
138and use a timeout on the
139.Xr select 2
140(or equivalent) call.
141.Sh BUGS
142The OpenSSL ASN1 functions cannot gracefully deal with non blocking I/O:
143they cannot retry after a partial read or write.
144This is usually worked around by only passing the relevant data to ASN1
145functions when the entire structure can be read or written.