Problem with latest OpenSSH - 2.5.2p2

Jim Knoble jmknoble at jmknoble.cx
Fri Apr 13 06:38:14 EST 2001


Circa 2001-Apr-12 15:16:37 +0200 dixit Lutz Jaenicke:

: On Thu, Apr 12, 2001 at 08:46:20AM -0400, Brent L. Bates wrote:
: >      The problem I am seeing is that every once and a while I get the
: > following error in the current OpenSSH connected window:
: > 
: >         `read: Interrupted function call'
: 
: I just did a grep on 'read:' and there is only one place where this error
: could be generated. It is in clientloop.c:client_process_input().

  [...]

: There is no check for EINTR (and EAGAIN), and the occurance of EINTR
: would be treated as error.
: Without fully analyzing the code (I just jumped into it), it should be
: sufficient to insert 
:                   if (len <= 0) {
:                         /*
:                          * Received EOF or error.  They are treated
:                          * similarly, except that an error message is printed
:                          * if it was an error condition.
:                          */
:                         if (len < 0) {
: +				if ((errno == EINTR) || (errno == EAGAIN))
: +					continue;

Don't you mean 'return;'?  There's no enclosing loop in
client_process_input().

:                                 snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno));

This technique doesn't restart the read() if it was interrupted.
Shouldn't it read something like the following?

  restart_interrupted:
     len = read(fileno(stdin), buf, sizeof(buf));
     if (len <= 0) {
        if (len < 0) {
           if (EINTR == errno) {
	      /* Interrupted by signal. */
              goto restart_interrupted;
           } else if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
	      /* Read operation would block; come back later. */
              return;
           } else {
	      /* An actual error. */
              snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno));
              buffer_append(&tderro_buffer, buf, strlen(buf));
           }
        }
        stdin_eof = 1;
        /* etc. */
     }

: PS. Operating systems tend to behave differently. I have never seen such
: effects on HP-UX, while e.g. Unixware behaves completely different, as
: I have learned when tracking down problems with EINTR in the EGD interface
: code of OpenSSL... Therefore it is well possible, that other people not
: working on Irix won't be able to reproduce this problem.

It may well depend on whether signals restart interrupted system calls
by default or not.  See APUE.

-- 
jim knoble | jmknoble at jmknoble.cx | http://www.jmknoble.cx/



More information about the openssh-unix-dev mailing list