git: 73df35607d08 - stable/13 - dma: update to 2022-01-27 snapshot
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 30 Jan 2022 17:55:09 UTC
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=73df35607d0894d82bdedce196edd6a809ad182f commit 73df35607d0894d82bdedce196edd6a809ad182f Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-01-27 19:30:58 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-01-30 17:54:56 +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) {