Problem with latest OpenSSH - 2.5.2p2

Wayne Davison wayne at blorf.net
Tue Apr 17 03:15:44 EST 2001


On Mon, 16 Apr 2001, Niels Provos wrote:
> Calling read() again is certainly wrong.  If you want that behaviour
> you should use atomicio(read, ...).

It looks like atomicio() hard-loops on EAGAIN and EWOULDBLOCK.
Shouldn't it have something like the following?

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: atomicio.c
--- openssh-2.5.2p2/atomicio.c	Sun Mar  4 22:59:27 2001
+++ ./atomicio.c	Mon Apr 16 10:02:10 2001
@@ -46,12 +46,27 @@
 		res = (f) (fd, s + pos, n - pos);
 		switch (res) {
 		case -1:
+			if (errno == EINTR)
+				continue;
+			if (errno == EAGAIN
 #ifdef EWOULDBLOCK
-			if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
-#else
-			if (errno == EINTR || errno == EAGAIN)
+			 || errno == EWOULDBLOCK
 #endif
+			   ) {
+				fd_set bits, *r, *w;
+				FD_ZERO(&bits);
+				FD_SET(fd, &bits);
+				if (f == read)
+					r = &bits, w = NULL;
+				else
+					r = NULL, w = &bits;
+				do {
+					res = select(fd+1, r, w, NULL, NULL);
+				} while (res == -1 && errno == EINTR);
+				if (res == -1)
+					return res;
 				continue;
+			}
 		case 0:
 			return (res);
 		default:
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---




More information about the openssh-unix-dev mailing list