summaryrefslogtreecommitdiff
path: root/atomicio.c
diff options
context:
space:
mode:
Diffstat (limited to 'atomicio.c')
-rw-r--r--atomicio.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/atomicio.c b/atomicio.c
index d91bd7621..e00c9f0d4 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.c,v 1.29 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: atomicio.c,v 1.30 2019/01/24 02:42:23 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2006 Damien Miller. All rights reserved. 3 * Copyright (c) 2006 Damien Miller. All rights reserved.
4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. 4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -57,9 +57,11 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
57 ssize_t res; 57 ssize_t res;
58 struct pollfd pfd; 58 struct pollfd pfd;
59 59
60#ifndef BROKEN_READ_COMPARISON
61 pfd.fd = fd; 60 pfd.fd = fd;
61#ifndef BROKEN_READ_COMPARISON
62 pfd.events = f == read ? POLLIN : POLLOUT; 62 pfd.events = f == read ? POLLIN : POLLOUT;
63#else
64 pfd.events = POLLIN|POLLOUT;
63#endif 65#endif
64 while (n > pos) { 66 while (n > pos) {
65 res = (f) (fd, s + pos, n - pos); 67 res = (f) (fd, s + pos, n - pos);
@@ -73,9 +75,7 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
73 } 75 }
74 continue; 76 continue;
75 } else if (errno == EAGAIN || errno == EWOULDBLOCK) { 77 } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
76#ifndef BROKEN_READ_COMPARISON
77 (void)poll(&pfd, 1, -1); 78 (void)poll(&pfd, 1, -1);
78#endif
79 continue; 79 continue;
80 } 80 }
81 return 0; 81 return 0;
@@ -119,9 +119,11 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
119 /* Make a copy of the iov array because we may modify it below */ 119 /* Make a copy of the iov array because we may modify it below */
120 memcpy(iov, _iov, (size_t)iovcnt * sizeof(*_iov)); 120 memcpy(iov, _iov, (size_t)iovcnt * sizeof(*_iov));
121 121
122#ifndef BROKEN_READV_COMPARISON
123 pfd.fd = fd; 122 pfd.fd = fd;
123#ifndef BROKEN_READV_COMPARISON
124 pfd.events = f == readv ? POLLIN : POLLOUT; 124 pfd.events = f == readv ? POLLIN : POLLOUT;
125#else
126 pfd.events = POLLIN|POLLOUT;
125#endif 127#endif
126 for (; iovcnt > 0 && iov[0].iov_len > 0;) { 128 for (; iovcnt > 0 && iov[0].iov_len > 0;) {
127 res = (f) (fd, iov, iovcnt); 129 res = (f) (fd, iov, iovcnt);
@@ -135,9 +137,7 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
135 } 137 }
136 continue; 138 continue;
137 } else if (errno == EAGAIN || errno == EWOULDBLOCK) { 139 } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
138#ifndef BROKEN_READV_COMPARISON
139 (void)poll(&pfd, 1, -1); 140 (void)poll(&pfd, 1, -1);
140#endif
141 continue; 141 continue;
142 } 142 }
143 return 0; 143 return 0;