]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Handle partial data re-sending on ktls/sendfile on FreeBSD
authorOleksandr Tymoshenko <gonzo@bluezbox.com>
Sun, 20 Dec 2020 19:01:53 +0000 (11:01 -0800)
committerMatt Caswell <matt@openssl.org>
Wed, 10 Feb 2021 09:14:33 +0000 (09:14 +0000)
Add a handler for EBUSY sendfile error in addition to
EAGAIN. With EBUSY returned the data still can be partially
sent and user code has to be notified about it, otherwise it
may try to send data multiple times.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13716)

doc/man3/SSL_write.pod
include/internal/ktls.h

index 06bd368c465b27906ea51865fce25627a93d6bf5..9a5a6f0744df86ea35b94a35022218d972e79457 100644 (file)
@@ -120,7 +120,8 @@ For SSL_sendfile(), the following return values can occur:
 =item Z<>>= 0
 
 The write operation was successful, the return value is the number
-of bytes of the file written to the TLS/SSL connection.
+of bytes of the file written to the TLS/SSL connection. The return
+value can be less than B<size> for a partial write.
 
 =item E<lt> 0
 
index 135f953ca21fbe0b9c7eaef61f10ff745efddcee..1f486e7b488abb8bdb3096f2b834883584db8ec3 100644 (file)
@@ -192,15 +192,12 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length)
 static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off,
                                               size_t size, int flags)
 {
-    off_t sbytes;
+    off_t sbytes = 0;
     int ret;
 
     ret = sendfile(fd, s, off, size, NULL, &sbytes, flags);
-    if (ret == -1) {
-           if (errno == EAGAIN && sbytes != 0)
-                   return sbytes;
-           return -1;
-    }
+    if (ret == -1 && sbytes == 0)
+        return -1;
     return sbytes;
 }