Problem with latest OpenSSH - 2.5.2p2

Niels Provos provos at citi.umich.edu
Tue Apr 17 00:29:26 EST 2001


In message <20010413163723.B5478 at quipu.half.pint-stowp.cx>, Jim Knoble writes:
>: diff -u -r1.61 clientloop.c
>: --- clientloop.c	2001/04/08 11:27:33	1.61
>: +++ clientloop.c	2001/04/13 14:07:41
>: @@ -671,7 +671,9 @@
>:  	/* Read input from stdin. */
>:  	if (FD_ISSET(fileno(stdin), readset)) {
>:  		/* Read as much as possible. */
>: -		len = read(fileno(stdin), buf, sizeof(buf));
>: +		do
>: +			len = read(fileno(stdin), buf, sizeof(buf));
>: +		while (len == -1 && (errno == EINTR || errno == EAGAIN));
>Damien, is stdin set up for non-blocking I/O at this point?  If it is,
>then retrying the read() after EAGAIN is liable to cause ssh to
>effectively block (by spinning in this loop) until there's some input
>on stdin.  If stdin isn't set up for non-blocking I/O, then why would
>read() return EAGAIN?
>
>Wouldn't it make more sense to simply return from
>client_process_input() on EAGAIN?
Given that this is already in a select() loop, a return value of -1
with either EINTR or EAGAIN should cause the loop to continue and
wait for the next select().

Calling read() again is certainly wrong.  If you want that behaviour
you should use atomicio(read, ...).

Niels.



More information about the openssh-unix-dev mailing list