]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
SSL_sendfile: make it more like bio/bss_sock.c:sock_write()
authorGleb Smirnoff <glebius@netflix.com>
Fri, 23 Jan 2026 18:44:23 +0000 (10:44 -0800)
committerNeil Horman <nhorman@openssl.org>
Wed, 18 Feb 2026 23:31:05 +0000 (18:31 -0500)
First, use BIO_sock_should_retry().

Second, clear BIO retry flags.  Otherwise after an SSL_sendfile that
failed, no matter how many succeded after, the flags would still be up.

Fixes: #29742
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Feb 18 23:31:24 2026
(Merged from https://github.com/openssl/openssl/pull/29744)

ssl/ssl_lib.c

index e30c3bba17adb17a82f509d29ac3ae1b9cec22fb..352f58911cbddb65a3f4ae8db42f44518a43bfb1 100644 (file)
@@ -2705,13 +2705,12 @@ ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags)
     return -1;
 #else
     ret = ktls_sendfile(SSL_get_wfd(s), fd, offset, size, &sbytes, flags);
+    BIO_clear_retry_flags(sc->wbio);
     if (ret < 0) {
-#if defined(EAGAIN) && defined(EINTR) && defined(EBUSY)
-        if ((get_last_sys_error() == EAGAIN) || (get_last_sys_error() == EINTR) || (get_last_sys_error() == EBUSY)) {
+        if (BIO_sock_should_retry(ret)) {
             BIO_set_retry_write(sc->wbio);
             return (sbytes > 0 ? sbytes : ret);
         } else
-#endif
             ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
                 "ktls_sendfile failure");
         return ret;