summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-06-26 05:16:38 +0000
committerDamien Miller <djm@mindrot.org>2020-06-26 15:25:24 +1000
commit3d06ff4bbd3dca8054c238d2a94c0da563ef7eee (patch)
tree8eb53997aaeaa09fe20f1f5b060b03c90f8f350f
parentfe2ec0b9c19adeab0cd9f04b8152dc17f31c31e5 (diff)
upstream: handle EINTR in waitfd() and timeout_connect() helpers;
bz#3071; ok dtucker@ OpenBSD-Commit-ID: 08fa87be50070bd8b754d9b1ebb1138d7bc9d8ee
-rw-r--r--misc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/misc.c b/misc.c
index f29e9bc3..4623b575 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.152 2020/05/29 11:17:56 dtucker Exp $ */
+/* $OpenBSD: misc.c,v 1.153 2020/06/26 05:16:38 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
@@ -253,7 +253,7 @@ waitfd(int fd, int *timeoutp, short events)
errno = oerrno;
if (r > 0)
return 0;
- else if (r == -1 && errno != EAGAIN)
+ else if (r == -1 && errno != EAGAIN && errno != EINTR)
return -1;
else if (r == 0)
break;
@@ -292,12 +292,17 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
return connect(sockfd, serv_addr, addrlen);
set_nonblock(sockfd);
- if (connect(sockfd, serv_addr, addrlen) == 0) {
- /* Succeeded already? */
- unset_nonblock(sockfd);
- return 0;
- } else if (errno != EINPROGRESS)
- return -1;
+ for (;;) {
+ if (connect(sockfd, serv_addr, addrlen) == 0) {
+ /* Succeeded already? */
+ unset_nonblock(sockfd);
+ return 0;
+ } else if (errno == EINTR)
+ continue;
+ else if (errno != EINPROGRESS)
+ return -1;
+ break;
+ }
if (waitfd(sockfd, timeoutp, POLLIN | POLLOUT) == -1)
return -1;