summaryrefslogtreecommitdiff
path: root/atomicio.c
diff options
context:
space:
mode:
Diffstat (limited to 'atomicio.c')
-rw-r--r--atomicio.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/atomicio.c b/atomicio.c
index f854a06f5..d91bd7621 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.c,v 1.28 2016/07/27 23:18:12 djm Exp $ */ 1/* $OpenBSD: atomicio.c,v 1.29 2019/01/23 08:01:46 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.
@@ -65,9 +65,14 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
65 res = (f) (fd, s + pos, n - pos); 65 res = (f) (fd, s + pos, n - pos);
66 switch (res) { 66 switch (res) {
67 case -1: 67 case -1:
68 if (errno == EINTR) 68 if (errno == EINTR) {
69 /* possible SIGALARM, update callback */
70 if (cb != NULL && cb(cb_arg, 0) == -1) {
71 errno = EINTR;
72 return pos;
73 }
69 continue; 74 continue;
70 if (errno == EAGAIN || errno == EWOULDBLOCK) { 75 } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
71#ifndef BROKEN_READ_COMPARISON 76#ifndef BROKEN_READ_COMPARISON
72 (void)poll(&pfd, 1, -1); 77 (void)poll(&pfd, 1, -1);
73#endif 78#endif
@@ -122,9 +127,14 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
122 res = (f) (fd, iov, iovcnt); 127 res = (f) (fd, iov, iovcnt);
123 switch (res) { 128 switch (res) {
124 case -1: 129 case -1:
125 if (errno == EINTR) 130 if (errno == EINTR) {
131 /* possible SIGALARM, update callback */
132 if (cb != NULL && cb(cb_arg, 0) == -1) {
133 errno = EINTR;
134 return pos;
135 }
126 continue; 136 continue;
127 if (errno == EAGAIN || errno == EWOULDBLOCK) { 137 } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
128#ifndef BROKEN_READV_COMPARISON 138#ifndef BROKEN_READV_COMPARISON
129 (void)poll(&pfd, 1, -1); 139 (void)poll(&pfd, 1, -1);
130#endif 140#endif