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)
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;