]> andersk Git - openssh.git/blobdiff - atomicio.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / atomicio.c
index afe3444c945c9a85b264ba602cdaaf2f24219ec9..a6b2d127a9b803a8e4e1c85359d351eaaabecaf9 100644 (file)
 #include <sys/uio.h>
 
 #include <errno.h>
+#ifdef HAVE_POLL_H
 #include <poll.h>
+#else
+# ifdef HAVE_SYS_POLL_H
+#  include <sys/poll.h>
+# endif
+#endif
 #include <string.h>
 #include <unistd.h>
 
@@ -55,13 +61,9 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
                res = (f) (fd, s + pos, n - pos);
                switch (res) {
                case -1:
-#ifdef EWOULDBLOCK
-                       if (errno == EINTR || errno == EWOULDBLOCK)
-#else
                        if (errno == EINTR)
-#endif
                                continue;
-                       if (errno == EAGAIN) {
+                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
                                (void)poll(&pfd, 1, -1);
                                continue;
                        }
@@ -95,20 +97,20 @@ atomiciov(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, iovcnt * sizeof(*_iov));
 
+#ifndef BROKEN_READV_COMPARISON
        pfd.fd = fd;
        pfd.events = f == readv ? POLLIN : POLLOUT;
+#endif
        for (; iovcnt > 0 && iov[0].iov_len > 0;) {
                res = (f) (fd, iov, iovcnt);
                switch (res) {
                case -1:
-#ifdef EWOULDBLOCK
-                       if (errno == EINTR || errno == EWOULDBLOCK)
-#else
                        if (errno == EINTR)
-#endif
                                continue;
-                       if (errno == EAGAIN) {
+                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
+#ifndef BROKEN_READV_COMPARISON
                                (void)poll(&pfd, 1, -1);
+#endif
                                continue;
                        }
                        return 0;
This page took 0.701717 seconds and 4 git commands to generate.