diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-06-26 07:16:38 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-06-26 07:25:24 +0200 |
commit | 3d06ff4bbd3dca8054c238d2a94c0da563ef7eee (patch) | |
tree | 8eb53997aaeaa09fe20f1f5b060b03c90f8f350f /misc.c | |
parent | upstream: allow "ssh-add -d -" to read keys to be deleted from (diff) | |
download | openssh-3d06ff4bbd3dca8054c238d2a94c0da563ef7eee.tar.xz openssh-3d06ff4bbd3dca8054c238d2a94c0da563ef7eee.zip |
upstream: handle EINTR in waitfd() and timeout_connect() helpers;
bz#3071; ok dtucker@
OpenBSD-Commit-ID: 08fa87be50070bd8b754d9b1ebb1138d7bc9d8ee
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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; |