Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Originating-IP: [24.0.161.175] From: "Karl M" To: cygwin AT cygwin DOT com Subject: ssh hanging--a workaround Date: Sat, 26 May 2001 14:22:15 -0700 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_6a03_72a7_7b8a" Message-ID: X-OriginalArrivalTime: 26 May 2001 21:22:16.0093 (UTC) FILETIME=[EFFFA4D0:01C0E629] ------=_NextPart_000_6a03_72a7_7b8a Content-Type: text/plain; format=flowed Hi Corinna... I don't have a solution to the ssh hanging problem when it is forked off as in ssh -f localhost sleep 10 but have a workaround. The patch file is attached. I looked at both ssh and sshd when they hang (both in their respective select calls--which makes sense because they are both waiting for something to do). The problem is in ssh. When ssh is forked after authentication, the select call fails to return after the fifth time that it is invoked. This problem only seems to occur when ssh has invoked daemon before starting the interactive session, but the problem shows up four select calls later. As part of my debugging, I forced select to return by setting a timeout. The timeout does force it to return--and in fact, there is IO waiting to be processed. So a one second timeout in the select call is my workaround for now. The read and write bit masks before and after the select call always look fine. It is not an ssh bug as far as I can tell. ssh localhost sleep 10 ssh -f localhost sleep 10 are the two test cases I used for debugging--to compare the behavior. Also, in the past, I needed pipes and you did not. Now we all have pipes. But why do you think that in the past, I needed pipes and you did not? Thanks, ...Karl _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com ------=_NextPart_000_6a03_72a7_7b8a Content-Type: text/plain; name="OpenSSH-2.9p1-Hang-Patch"; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="OpenSSH-2.9p1-Hang-Patch" diff -U 8 -r /openssh-2.9p1/clientloop.c ./clientloop.c --- /openssh-2.9p1/clientloop.c Fri Apr 20 05:50:52 2001 +++ ./clientloop.c Sat May 26 12:36:32 2001 @@ -319,16 +319,26 @@ * Waits until the client can do something (some data becomes available on * one of the file descriptors). */ void client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, int rekeying) { +#ifdef HAVE_CYGWIN + /* + * For CygWin, set a 1 secound timeout to prevent hanging + * in the select call. + */ + struct timeval tv; + tv.tv_sec = 1; + tv.tv_usec = 0; +#endif + /* Add any selections by the channel mechanism. */ channel_prepare_select(readsetp, writesetp, maxfdp, rekeying); if (!compat20) { /* Read from the connection, unless our buffers are full. */ if (buffer_len(&stdout_buffer) < buffer_high && buffer_len(&stderr_buffer) < buffer_high && channel_not_very_much_buffered_data()) @@ -357,17 +367,21 @@ * Wait for something to happen. This will suspend the process until * some selected descriptor can be read, written, or has some other * event pending. Note: if you want to implement SSH_MSG_IGNORE * messages to fool traffic analysis, this might be the place to do * it: just have a random timeout for the select, and send a random * SSH_MSG_IGNORE packet when the timeout expires. */ +#ifdef HAVE_CYGWIN + if (select((*maxfdp)+1, *readsetp, *writesetp, NULL, &tv) < 0) { +#else if (select((*maxfdp)+1, *readsetp, *writesetp, NULL, NULL) < 0) { +#endif char buf[100]; /* * We have to clear the select masks, because we return. * We have to return, because the mainloop checks for the flags * set by the signal handlers. */ memset(*readsetp, 0, *maxfdp); ------=_NextPart_000_6a03_72a7_7b8a Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple ------=_NextPart_000_6a03_72a7_7b8a--