diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2020-06-26 05:16:39 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2020-06-26 05:16:39 +0000 |
commit | 5a78488742556542df5f26ba812c30b08c664d8b (patch) | |
tree | 885c6434486370331b65d1f26928b9d6c7959822 /usr.bin | |
parent | c5e56af01d4679187effd6452aaf789408f13d5a (diff) |
handle EINTR in waitfd() and timeout_connect() helpers;
bz#3071; ok dtucker@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/misc.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index ec869aea41b..c63f4672ef7 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/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. @@ -226,7 +226,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; @@ -265,12 +265,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; |