]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
For broken read/readv comparisons, poll(RW).
authorDarren Tucker <dtucker@dtucker.net>
Wed, 23 Jan 2019 23:00:20 +0000 (10:00 +1100)
committerDarren Tucker <dtucker@dtucker.net>
Wed, 23 Jan 2019 23:07:03 +0000 (10:07 +1100)
In the cases where we can't compare to read or readv function pointers
for some reason we currently ifdef out the poll() used to block while
waiting for reads or writes, falling back to busy waiting.  This restores
the poll() in this case, but has it always check for read or write,
removing an inline ifdef in the process.

atomicio.c

index f854a06f5f5099e984b0c6d020b4bb7039c9e7a0..cffa9fa7d0c3b857e90592b1288f3ef57e5743b4 100644 (file)
@@ -57,9 +57,11 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
        ssize_t res;
        struct pollfd pfd;
 
-#ifndef BROKEN_READ_COMPARISON
        pfd.fd = fd;
+#ifndef BROKEN_READ_COMPARISON
        pfd.events = f == read ? POLLIN : POLLOUT;
+#else
+       pfd.events = POLLIN|POLLOUT;
 #endif
        while (n > pos) {
                res = (f) (fd, s + pos, n - pos);
@@ -68,9 +70,7 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
                        if (errno == EINTR)
                                continue;
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
-#ifndef BROKEN_READ_COMPARISON
                                (void)poll(&pfd, 1, -1);
-#endif
                                continue;
                        }
                        return 0;
@@ -114,9 +114,11 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
        /* Make a copy of the iov array because we may modify it below */
        memcpy(iov, _iov, (size_t)iovcnt * sizeof(*_iov));
 
-#ifndef BROKEN_READV_COMPARISON
        pfd.fd = fd;
+#ifndef BROKEN_READV_COMPARISON
        pfd.events = f == readv ? POLLIN : POLLOUT;
+#else
+       pfd.events = POLLIN|POLLOUT;
 #endif
        for (; iovcnt > 0 && iov[0].iov_len > 0;) {
                res = (f) (fd, iov, iovcnt);
@@ -125,9 +127,7 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
                        if (errno == EINTR)
                                continue;
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
-#ifndef BROKEN_READV_COMPARISON
                                (void)poll(&pfd, 1, -1);
-#endif
                                continue;
                        }
                        return 0;