]> andersk Git - openssh.git/commitdiff
- (djm) [atomicio.c channels.c clientloop.c defines.h includes.h]
authordjm <djm>
Fri, 4 Jul 2008 13:10:49 +0000 (13:10 +0000)
committerdjm <djm>
Fri, 4 Jul 2008 13:10:49 +0000 (13:10 +0000)
   [packet.c scp.c serverloop.c sftp-client.c ssh-agent.c ssh-keyscan.c]
   [sshd.c] Explicitly handle EWOULDBLOCK wherever we handle EAGAIN, on
   some platforms (HP nonstop) it is a distinct errno;
   bz#1467 reported by sconeu AT yahoo.com; ok dtucker@

13 files changed:
ChangeLog
atomicio.c
channels.c
clientloop.c
defines.h
includes.h
packet.c
scp.c
serverloop.c
sftp-client.c
ssh-agent.c
ssh-keyscan.c
sshd.c

index 7c2333c68a309e8c2e90e4277d1fd2440436f93c..4ba39aa362364df7ab4a5ada49435e83ac3c00d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      explicitly disable conch options that could interfere with the test
  - (dtucker) [sftp-server.c] Bug #1447: fall back to racy rename if link
    returns EXDEV.  Patch from Mike Garrison, ok djm@
-h
+ - (djm) [atomicio.c channels.c clientloop.c defines.h includes.h]
+   [packet.c scp.c serverloop.c sftp-client.c ssh-agent.c ssh-keyscan.c]
+   [sshd.c] Explicitly handle EWOULDBLOCK wherever we handle EAGAIN, on
+   some platforms (HP nonstop) it is a distinct errno;
+   bz#1467 reported by sconeu AT yahoo.com; ok dtucker@
+
 20080702
  - (dtucker) OpenBSD CVS Sync
     - djm@cvs.openbsd.org 2008/06/30 08:05:59
index 575bf8900ee39e9e3cb89061934b659bd87b52d6..bb44c32300d368b77f84b9d22adb1c229e34b88b 100644 (file)
@@ -63,11 +63,7 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
                case -1:
                        if (errno == EINTR)
                                continue;
-#ifdef EWOULDBLOCK
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
-#else
-                       if (errno == EAGAIN) {
-#endif
                                (void)poll(&pfd, 1, -1);
                                continue;
                        }
@@ -109,11 +105,7 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
                case -1:
                        if (errno == EINTR)
                                continue;
-#ifdef EWOULDBLOCK
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
-#else
-                       if (errno == EAGAIN) {
-#endif
                                (void)poll(&pfd, 1, -1);
                                continue;
                        }
index 7f0aaadf680dc80a4abfc09e542e2485df9f854c..ac5134b5ba43e6c83d8092d67085d3fd9f5f4025 100644 (file)
@@ -1494,7 +1494,8 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset)
        if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
                errno = 0;
                len = read(c->rfd, buf, sizeof(buf));
-               if (len < 0 && (errno == EINTR || (errno == EAGAIN && !force)))
+               if (len < 0 && (errno == EINTR ||
+                   ((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))
                        return 1;
 #ifndef PTY_ZEROREAD
                if (len <= 0) {
@@ -1565,7 +1566,8 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
                        c->local_consumed += dlen + 4;
                        len = write(c->wfd, buf, dlen);
                        xfree(data);
-                       if (len < 0 && (errno == EINTR || errno == EAGAIN))
+                       if (len < 0 && (errno == EINTR || errno == EAGAIN ||
+                           errno == EWOULDBLOCK))
                                return 1;
                        if (len <= 0) {
                                if (c->type != SSH_CHANNEL_OPEN)
@@ -1583,7 +1585,8 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
 #endif
 
                len = write(c->wfd, buf, dlen);
-               if (len < 0 && (errno == EINTR || errno == EAGAIN))
+               if (len < 0 &&
+                   (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
                        return 1;
                if (len <= 0) {
                        if (c->type != SSH_CHANNEL_OPEN) {
@@ -1635,7 +1638,8 @@ channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset)
                            buffer_len(&c->extended));
                        debug2("channel %d: written %d to efd %d",
                            c->self, len, c->efd);
-                       if (len < 0 && (errno == EINTR || errno == EAGAIN))
+                       if (len < 0 && (errno == EINTR || errno == EAGAIN ||
+                           errno == EWOULDBLOCK))
                                return 1;
                        if (len <= 0) {
                                debug2("channel %d: closing write-efd %d",
@@ -1650,8 +1654,8 @@ channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset)
                        len = read(c->efd, buf, sizeof(buf));
                        debug2("channel %d: read %d from efd %d",
                            c->self, len, c->efd);
-                       if (len < 0 && (errno == EINTR ||
-                           (errno == EAGAIN && !c->detach_close)))
+                       if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
+                           errno == EWOULDBLOCK) && !c->detach_close)))
                                return 1;
                        if (len <= 0) {
                                debug2("channel %d: closing read-efd %d",
@@ -1675,7 +1679,8 @@ channel_handle_ctl(Channel *c, fd_set *readset, fd_set *writeset)
        /* Monitor control fd to detect if the slave client exits */
        if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
                len = read(c->ctl_fd, buf, sizeof(buf));
-               if (len < 0 && (errno == EINTR || errno == EAGAIN))
+               if (len < 0 &&
+                   (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
                        return 1;
                if (len <= 0) {
                        debug2("channel %d: ctl read<=0", c->self);
index 6dc870881b54af351777efb829c20af5b7d77371..ba2f0b79e63046d404dc3281d2c6735398e67a06 100644 (file)
@@ -663,7 +663,8 @@ client_process_net_input(fd_set *readset)
                 * There is a kernel bug on Solaris that causes select to
                 * sometimes wake up even though there is no data available.
                 */
-               if (len < 0 && (errno == EAGAIN || errno == EINTR))
+               if (len < 0 &&
+                   (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
                        len = 0;
 
                if (len < 0) {
@@ -1129,7 +1130,8 @@ client_process_input(fd_set *readset)
        if (FD_ISSET(fileno(stdin), readset)) {
                /* Read as much as possible. */
                len = read(fileno(stdin), buf, sizeof(buf));
-               if (len < 0 && (errno == EAGAIN || errno == EINTR))
+               if (len < 0 &&
+                   (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
                        return;         /* we'll try again later */
                if (len <= 0) {
                        /*
@@ -1186,7 +1188,8 @@ client_process_output(fd_set *writeset)
                len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
                    buffer_len(&stdout_buffer));
                if (len <= 0) {
-                       if (errno == EINTR || errno == EAGAIN)
+                       if (errno == EINTR || errno == EAGAIN ||
+                           errno == EWOULDBLOCK)
                                len = 0;
                        else {
                                /*
@@ -1210,7 +1213,8 @@ client_process_output(fd_set *writeset)
                len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
                    buffer_len(&stderr_buffer));
                if (len <= 0) {
-                       if (errno == EINTR || errno == EAGAIN)
+                       if (errno == EINTR || errno == EAGAIN ||
+                           errno == EWOULDBLOCK)
                                len = 0;
                        else {
                                /*
index a4893b6f7ccc5bfcfb278f7dd0bcd61c2027a1b4..febc590602756998241ddf03dcd80211d5c1d087 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -734,4 +734,8 @@ struct winsize {
 # endif
 #endif
 
+#ifndef EWOULDBLOCK
+# define EWOULDBLOCK EAGAIN
+#endif
+
 #endif /* _DEFINES_H */
index 9fcf1b023287c0965f0263086da78085cc666aee..f1b47f666d038b69aa98721b4d455b6094a48210 100644 (file)
 # include <sys/syslog.h>
 #endif
 
+#include <errno.h>
+
 /*
  * On HP-UX 11.11, shadow.h and prot.h provide conflicting declarations
  * of getspnam when _INCLUDE__STDC__ is defined, so we unset it here.
index 90ad5ff6792bcf344b5dc3e634a004c246d6bd86..ff22be68f4c49b1d9658149e52d4b28c50e46264 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -956,7 +956,8 @@ packet_read_seqnr(u_int32_t *seqnr_p)
                        if ((ret = select(connection_in + 1, setp, NULL,
                            NULL, timeoutp)) >= 0)
                                break;
-                       if (errno != EAGAIN && errno != EINTR)
+                       if (errno != EAGAIN && errno != EINTR &&
+                           errno != EWOULDBLOCK)
                                break;
                        if (packet_timeout_ms == -1)
                                continue;
@@ -1475,7 +1476,7 @@ packet_write_poll(void)
        if (len > 0) {
                len = write(connection_out, buffer_ptr(&output), len);
                if (len <= 0) {
-                       if (errno == EAGAIN)
+                       if (errno == EAGAIN || errno == EWOULDBLOCK)
                                return;
                        else
                                fatal("Write failed: %.100s", strerror(errno));
@@ -1516,7 +1517,8 @@ packet_write_wait(void)
                        if ((ret = select(connection_out + 1, NULL, setp,
                            NULL, timeoutp)) >= 0)
                                break;
-                       if (errno != EAGAIN && errno != EINTR)
+                       if (errno != EAGAIN && errno != EINTR &&
+                           errno != EWOULDBLOCK)
                                break;
                        if (packet_timeout_ms == -1)
                                continue;
diff --git a/scp.c b/scp.c
index 46433a63847d2d878ae0daa5e4204016877e1c25..9f8b7a192ac6702dd9f4fe9e43a14e81a9a1370f 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -474,7 +474,7 @@ scpio(ssize_t (*f)(int, void *, size_t), int fd, void *_p, size_t l, off_t *c)
                if (r < 0) {
                        if (errno == EINTR)
                                continue;
-                       if (errno == EAGAIN) {
+                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
                                (void)poll(&pfd, 1, -1); /* Ignore errors */
                                continue;
                        }
index bd6f82dc1ade858f9da75ac53c1c4f6599fb2d0b..77d9dee75ceb9c26de8b1b04f3d00d6b6b939b4b 100644 (file)
@@ -400,7 +400,8 @@ process_input(fd_set *readset)
                                return;
                        cleanup_exit(255);
                } else if (len < 0) {
-                       if (errno != EINTR && errno != EAGAIN) {
+                       if (errno != EINTR && errno != EAGAIN &&
+                           errno != EWOULDBLOCK) {
                                verbose("Read error from remote host "
                                    "%.100s: %.100s",
                                    get_remote_ipaddr(), strerror(errno));
@@ -418,8 +419,8 @@ process_input(fd_set *readset)
        if (!fdout_eof && FD_ISSET(fdout, readset)) {
                errno = 0;
                len = read(fdout, buf, sizeof(buf));
-               if (len < 0 && (errno == EINTR ||
-                   (errno == EAGAIN && !child_terminated))) {
+               if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
+                   errno == EWOULDBLOCK) && !child_terminated))) {
                        /* do nothing */
 #ifndef PTY_ZEROREAD
                } else if (len <= 0) {
@@ -437,8 +438,8 @@ process_input(fd_set *readset)
        if (!fderr_eof && FD_ISSET(fderr, readset)) {
                errno = 0;
                len = read(fderr, buf, sizeof(buf));
-               if (len < 0 && (errno == EINTR ||
-                   (errno == EAGAIN && !child_terminated))) {
+               if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
+                   errno == EWOULDBLOCK) && !child_terminated))) {
                        /* do nothing */
 #ifndef PTY_ZEROREAD
                } else if (len <= 0) {
@@ -469,7 +470,8 @@ process_output(fd_set *writeset)
                data = buffer_ptr(&stdin_buffer);
                dlen = buffer_len(&stdin_buffer);
                len = write(fdin, data, dlen);
-               if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
+               if (len < 0 &&
+                   (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) {
                        /* do nothing */
                } else if (len <= 0) {
                        if (fdin != fdout)
index 42bf0c813df8241f7c4dc41ab735c42781ee23e7..5e39aa7d21bd6f8b309d1e774c0230ed7fc75aa9 100644 (file)
@@ -1223,7 +1223,8 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
                        len = 0;
                else do
                        len = read(local_fd, data, conn->transfer_buflen);
-               while ((len == -1) && (errno == EINTR || errno == EAGAIN));
+               while ((len == -1) &&
+                   (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
 
                if (len == -1)
                        fatal("Couldn't read from \"%s\": %s", local_path,
index b1c65fab6ce4df50c86fecced77997fb01d7360a..9123cfe6baf886b087c95c139ef2d96811231634 100644 (file)
@@ -961,7 +961,8 @@ after_select(fd_set *readset, fd_set *writeset)
                                            buffer_ptr(&sockets[i].output),
                                            buffer_len(&sockets[i].output));
                                        if (len == -1 && (errno == EAGAIN ||
-                                           errno == EINTR))
+                                           errno == EINTR ||
+                                           errno == EWOULDBLOCK))
                                                continue;
                                        break;
                                } while (1);
@@ -975,7 +976,8 @@ after_select(fd_set *readset, fd_set *writeset)
                                do {
                                        len = read(sockets[i].fd, buf, sizeof(buf));
                                        if (len == -1 && (errno == EAGAIN ||
-                                           errno == EINTR))
+                                           errno == EINTR ||
+                                           errno == EWOULDBLOCK))
                                                continue;
                                        break;
                                } while (1);
index 304fcfde8670af75ae9077f7205b97f6b4bc6e3e..d810777646e4fc8d434bc452d999344630b1c4b5 100644 (file)
@@ -656,7 +656,7 @@ conloop(void)
        memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
 
        while (select(maxfd, r, NULL, e, &seltime) == -1 &&
-           (errno == EAGAIN || errno == EINTR))
+           (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
                ;
 
        for (i = 0; i < maxfd; i++) {
diff --git a/sshd.c b/sshd.c
index c952f7ad2bb904619e55c92a5b9704ba2dc38495..a6620a05a822b356b785714eccb6a6fe3478bfa6 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -1096,7 +1096,8 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
                        *newsock = accept(listen_socks[i],
                            (struct sockaddr *)&from, &fromlen);
                        if (*newsock < 0) {
-                               if (errno != EINTR && errno != EWOULDBLOCK)
+                               if (errno != EINTR && errno != EAGAIN &&
+                                   errno != EWOULDBLOCK)
                                        error("accept: %.100s", strerror(errno));
                                continue;
                        }
This page took 0.136136 seconds and 5 git commands to generate.