diff options
author | Darren Tucker <dtucker@dtucker.net> | 2019-01-24 10:00:20 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2019-01-24 10:07:03 +1100 |
commit | 6249451f381755f792c6b9e2c2f80cdc699c14e2 (patch) | |
tree | 5909fd23edac8e9e304848839b355dbe9fc97a87 /atomicio.c | |
parent | 5cb503dff4db251520e8bf7d23b9c97c06eee031 (diff) | |
download | openssh-git-6249451f381755f792c6b9e2c2f80cdc699c14e2.tar.gz |
For broken read/readv comparisons, poll(RW).
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.
Diffstat (limited to 'atomicio.c')
-rw-r--r-- | atomicio.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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; |