From bbae91361a027693030d57d9f83118f3130f21cc Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 20 Dec 2022 14:55:45 +0000 Subject: [PATCH] document BIO_fd_non_fatal_error(3) and BIO_fd_should_retry(3) --- lib/libcrypto/man/BIO_s_fd.3 | 84 ++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/lib/libcrypto/man/BIO_s_fd.3 b/lib/libcrypto/man/BIO_s_fd.3 index 5ac33e77ee6..a22ba5d6039 100644 --- a/lib/libcrypto/man/BIO_s_fd.3 +++ b/lib/libcrypto/man/BIO_s_fd.3 @@ -1,7 +1,24 @@ -.\" $OpenBSD: BIO_s_fd.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ -.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 +.\" $OpenBSD: BIO_s_fd.3,v 1.10 2022/12/20 14:55:45 schwarze Exp $ +.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" -.\" This file was written by Dr. Stephen Henson . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Dr. Stephen Henson . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -48,14 +65,16 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 1 2018 $ +.Dd $Mdocdate: December 20 2022 $ .Dt BIO_S_FD 3 .Os .Sh NAME .Nm BIO_s_fd , .Nm BIO_set_fd , .Nm BIO_get_fd , -.Nm BIO_new_fd +.Nm BIO_new_fd , +.Nm BIO_fd_non_fatal_error , +.Nm BIO_fd_should_retry .Nd file descriptor BIO .Sh SYNOPSIS .In openssl/bio.h @@ -79,6 +98,10 @@ .Fa "int fd" .Fa "int close_flag" .Fc +.Ft int +.Fn BIO_fd_non_fatal_error "int errnum" +.Ft int +.Fn BIO_fd_should_retry "int retval" .Sh DESCRIPTION .Fn BIO_s_fd returns the file descriptor BIO method. @@ -140,6 +163,25 @@ returns a file descriptor BIO using and .Fa close_flag . .Pp +.Fn BIO_fd_non_fatal_error +determines whether the error status code +.Fa errnum +represents a recoverable error. +.Fn BIO_fd_should_retry +determines whether a recoverable error occurred by inspecting both +.Xr errno 2 +and +.Fa retval , +which is supposed to usually be +the return value of a previously called function like +.Xr BIO_read 3 +or +.Xr BIO_write 3 . +These two functions are mostly used internally; in application code, +it is usually easier and more robust to use +.Xr BIO_should_retry 3 , +which works for any BIO type. +.Pp The behaviour of .Xr BIO_read 3 and @@ -181,6 +223,27 @@ returns the newly allocated or .Dv NULL if an error occurred. +.Pp +.Fn BIO_fd_non_fatal_error +returns 1 if +.Fa errnum +is +.Dv EAGAIN , +.Dv EALREADY , +.Dv EINPROGRESS , +.Dv EINTR , +or +.Dv ENOTCONN +and 0 otherwise, even if +.Fa errnum +is 0. +.Pp +.Fn BIO_fd_should_retry +returns 1 if +.Fn BIO_fd_non_fatal_error errno +is 1 and +.Fa retval +is either 0 or \-1, or 0 otherwise. .Sh EXAMPLES This is a file descriptor BIO version of "Hello World": .Bd -literal -offset indent @@ -193,14 +256,19 @@ BIO_free(out); .Xr BIO_new 3 , .Xr BIO_read 3 , .Xr BIO_s_socket 3 , -.Xr BIO_seek 3 +.Xr BIO_seek 3 , +.Xr BIO_should_retry 3 .Sh HISTORY .Fn BIO_s_fd , .Fn BIO_set_fd , and .Fn BIO_get_fd -first appeared in SSLeay 0.6.0. +first appeared in SSLeay 0.6.0, +.Fn BIO_fd_should_retry +in SSLeay 0.6.5, and .Fn BIO_new_fd -first appeared in SSLeay 0.8.0. +and +.Fn BIO_fd_non_fatal_error +in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . -- 2.20.1