The branch stable/12 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=27941a274ebff0dbe94964e584101fece7967d96

commit 27941a274ebff0dbe94964e584101fece7967d96
Author:     Ed Maste <[email protected]>
AuthorDate: 2022-01-27 19:30:58 +0000
Commit:     Ed Maste <[email protected]>
CommitDate: 2022-01-30 17:55:47 +0000

    dma: update to 2022-01-27 snapshot
    
    (cherry picked from commit d045091ea25c916412474b4f7a9423c5d35b231f)
---
 contrib/dma/net.c | 51 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/contrib/dma/net.c b/contrib/dma/net.c
index e8e2634a9386..0079875a22e0 100644
--- a/contrib/dma/net.c
+++ b/contrib/dma/net.c
@@ -95,25 +95,29 @@ send_remote_command(int fd, const char* fmt, ...)
        strcat(cmd, "\r\n");
        len = strlen(cmd);
 
-       if (((config.features & SECURETRANSFER) != 0) &&
-           ((config.features & NOSSL) == 0)) {
-               while ((s = SSL_write(config.ssl, (const char*)cmd, len)) <= 0) 
{
-                       s = SSL_get_error(config.ssl, s);
-                       if (s != SSL_ERROR_WANT_READ &&
-                           s != SSL_ERROR_WANT_WRITE) {
-                               strlcpy(neterr, ssl_errstr(), sizeof(neterr));
-                               return (-1);
+       pos = 0;
+       while (pos < len) {
+               if (((config.features & SECURETRANSFER) != 0) &&
+                   ((config.features & NOSSL) == 0)) {
+                       if ((n = SSL_write(config.ssl, (const char*)(cmd + 
pos), len - pos)) <= 0) {
+                               s = SSL_get_error(config.ssl, n);
+                               if (s == SSL_ERROR_ZERO_RETURN ||
+                                   s == SSL_ERROR_SYSCALL ||
+                                   s == SSL_ERROR_SSL) {
+                                       strlcpy(neterr, ssl_errstr(), 
sizeof(neterr));
+                                       return (-1);
+                               }
+                               n = 0;
                        }
-               }
-       }
-       else {
-               pos = 0;
-               while (pos < len) {
+               } else {
                        n = write(fd, cmd + pos, len - pos);
-                       if (n < 0)
-                               return (-1);
-                       pos += n;
+                       if (n < 0) {
+                               if ((errno != EAGAIN) && (errno != EINTR))
+                                       return (-1);
+                               n = 0;
+                       }
                }
+               pos += n;
        }
 
        return (len);
@@ -150,9 +154,18 @@ read_remote(int fd, int extbufsize, char *extbuf)
                        pos = 0;
                        if (((config.features & SECURETRANSFER) != 0) &&
                            (config.features & NOSSL) == 0) {
-                               if ((rlen = SSL_read(config.ssl, buff + len, 
sizeof(buff) - len)) == -1) {
-                                       strlcpy(neterr, ssl_errstr(), 
sizeof(neterr));
-                                       goto error;
+                               if ((rlen = SSL_read(config.ssl, buff + len, 
sizeof(buff) - len)) <= 0) {
+                                       switch (SSL_get_error(config.ssl, 
rlen)) {
+                                       case SSL_ERROR_ZERO_RETURN:
+                                       case SSL_ERROR_SYSCALL:
+                                       case SSL_ERROR_SSL:
+                                               strlcpy(neterr, ssl_errstr(), 
sizeof(neterr));
+                                               goto error;
+                                       default:
+                                               /* in case of recoverable 
error, retry after short sleep */
+                                               usleep(10000);
+                                               continue;
+                                       }
                                }
                        } else {
                                if ((rlen = read(fd, buff + len, sizeof(buff) - 
len)) == -1) {

Reply via email to