diff options
| author | schwarze <> | 2015-02-16 16:42:14 +0000 |
|---|---|---|
| committer | schwarze <> | 2015-02-16 16:42:14 +0000 |
| commit | 9a3026fb0a89a15ea2def3629cc13a69f1fc678c (patch) | |
| tree | 28ac935f3dd22b133413a78861848f9501389a34 /src/lib/libcrypto/man/BIO_should_retry.3 | |
| parent | 4ab59c54f9da1075f740a1004c326b0784ed4de0 (diff) | |
| download | openbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.tar.gz openbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.tar.bz2 openbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.zip | |
third batch of perlpod(1) to mdoc(7) conversion
Diffstat (limited to 'src/lib/libcrypto/man/BIO_should_retry.3')
| -rw-r--r-- | src/lib/libcrypto/man/BIO_should_retry.3 | 145 |
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 | ||
| 37 | These functions determine why a BIO is not able to read or write data. | ||
| 38 | They will typically be called after a failed | ||
| 39 | .Xr BIO_read 3 | ||
| 40 | or | ||
| 41 | .Xr BIO_write 3 | ||
| 42 | call. | ||
| 43 | .Pp | ||
| 44 | .Fn BIO_should_retry | ||
| 45 | is true if the call that produced this condition | ||
| 46 | should be retried at a later time. | ||
| 47 | .Pp | ||
| 48 | If | ||
| 49 | .Fn BIO_should_retry | ||
| 50 | is false, the cause is an error condition. | ||
| 51 | .Pp | ||
| 52 | .Fn BIO_should_read | ||
| 53 | is true if the cause of the condition is that a BIO needs to read data. | ||
| 54 | .Pp | ||
| 55 | .Fn BIO_should_write | ||
| 56 | is true if the cause of the condition is that a BIO needs to write data. | ||
| 57 | .Pp | ||
| 58 | .Fn BIO_should_io_special | ||
| 59 | is true if some "special" condition, that is a reason other than | ||
| 60 | reading or writing, is the cause of the condition. | ||
| 61 | .Pp | ||
| 62 | .Fn BIO_retry_type | ||
| 63 | returns 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 | ||
| 67 | though current BIO types will only set one of these. | ||
| 68 | .Pp | ||
| 69 | .Fn BIO_get_retry_BIO | ||
| 70 | determines the precise reason for the special condition. | ||
| 71 | It returns the BIO that caused this condition and if | ||
| 72 | .Fa reason | ||
| 73 | is not | ||
| 74 | .Dv NULL | ||
| 75 | it contains the reason code. | ||
| 76 | The meaning of the reason code and the action that should be taken | ||
| 77 | depends on the type of BIO that resulted in this condition. | ||
| 78 | .Pp | ||
| 79 | .Fn BIO_get_retry_reason | ||
| 80 | returns the reason for a special condition | ||
| 81 | if passed the relevant BIO, for example as returned by | ||
| 82 | .Fn BIO_get_retry_BIO . | ||
| 83 | .Sh NOTES | ||
| 84 | If | ||
| 85 | .Fn BIO_should_retry | ||
| 86 | returns false, then the precise "error condition" depends on | ||
| 87 | the BIO type that caused it and the return code of the BIO operation. | ||
| 88 | For example if a call to | ||
| 89 | .Xr BIO_read 3 | ||
| 90 | on a socket BIO returns 0 and | ||
| 91 | .Fn BIO_should_retry | ||
| 92 | is false, then the cause will be that the connection closed. | ||
| 93 | A similar condition on a file BIO will mean that it has reached EOF. | ||
| 94 | Some BIO types may place additional information on the error queue. | ||
| 95 | For more details see the individual BIO type manual pages. | ||
| 96 | .Pp | ||
| 97 | If the underlying I/O structure is in a blocking mode, | ||
| 98 | almost all current BIO types will not request a retry, | ||
| 99 | because the underlying I/O calls will not. | ||
| 100 | If the application knows that the BIO type will never | ||
| 101 | signal a retry then it need not call | ||
| 102 | .Fn BIO_should_retry | ||
| 103 | after a failed BIO I/O call. | ||
| 104 | This is typically done with file BIOs. | ||
| 105 | .Pp | ||
| 106 | SSL BIOs are the only current exception to this rule: | ||
| 107 | they can request a retry even if the underlying I/O structure | ||
| 108 | is blocking, if a handshake occurs during a call to | ||
| 109 | .Xr BIO_read 3 . | ||
| 110 | An application can retry the failed call immediately | ||
| 111 | or avoid this situation by setting | ||
| 112 | .Dv SSL_MODE_AUTO_RETRY | ||
| 113 | on the underlying SSL structure. | ||
| 114 | .Pp | ||
| 115 | While an application may retry a failed non blocking call immediately, | ||
| 116 | this is likely to be very inefficient because the call will fail | ||
| 117 | repeatedly until data can be processed or is available. | ||
| 118 | An application will normally wait until the necessary condition | ||
| 119 | is satisfied. | ||
| 120 | How this is done depends on the underlying I/O structure. | ||
| 121 | .Pp | ||
| 122 | For example if the cause is ultimately a socket and | ||
| 123 | .Fn BIO_should_read | ||
| 124 | is true then a call to | ||
| 125 | .Xr select 2 | ||
| 126 | may be made to wait until data is available | ||
| 127 | and then retry the BIO operation. | ||
| 128 | By combining the retry conditions of several non blocking BIOs in a single | ||
| 129 | .Xr select 2 | ||
| 130 | call it is possible to service several BIOs in a single thread, | ||
| 131 | though the performance may be poor if SSL BIOs are present because | ||
| 132 | long delays can occur during the initial handshake process. | ||
| 133 | .Pp | ||
| 134 | It is possible for a BIO to block indefinitely if the underlying I/O | ||
| 135 | structure cannot process or return any data. | ||
| 136 | This depends on the behaviour of the platforms I/O functions. | ||
| 137 | This is often not desirable: one solution is to use non blocking I/O | ||
| 138 | and use a timeout on the | ||
| 139 | .Xr select 2 | ||
| 140 | (or equivalent) call. | ||
| 141 | .Sh BUGS | ||
| 142 | The OpenSSL ASN1 functions cannot gracefully deal with non blocking I/O: | ||
| 143 | they cannot retry after a partial read or write. | ||
| 144 | This is usually worked around by only passing the relevant data to ASN1 | ||
| 145 | functions when the entire structure can be read or written. | ||
