delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/27/10:11:48

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
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" <karlm30 AT hotmail DOT com>
To: cygwin AT cygwin DOT com
Subject: ssh hanging with -f option--a workaround
Date: Fri, 27 Jul 2001 07:08:31 -0700
Mime-Version: 1.0
Message-ID: <F114mOlbcrYP0QzBxhJ000076bf@hotmail.com>
X-OriginalArrivalTime: 27 Jul 2001 14:08:32.0011 (UTC) FILETIME=[9E0C5DB0:01C116A5]

------=_NextPart_000_afb_12ee_41ee
Content-Type: text/plain; format=flowed

Hi All...

I first saw the following problem with openssh-2.5.2p1 or 2.9p1. The problem 
is that when I use the -f option with the ssh client, it hangs (with 
CygWin). I checked my patch file against openssh-2.9p2-3. Because several 
others have had this same problem, my updated patch is attached for anyone 
who needs to use the -f option to ssh.

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.

Thanks,

...Karl



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

------=_NextPart_000_afb_12ee_41ee
Content-Type: text/plain; name="OpenSSH-2.9p2-3-Hang-Patch"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="OpenSSH-2.9p2-3-Hang-Patch"

diff -U 8 -r /openssh-2.9p2-3/clientloop.c ./clientloop.c
--- /openssh-2.9p2-3/clientloop.c	Fri Apr 20 05:50:51 2001
+++ ./clientloop.c	Fri Jul 27 06:28:16 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);
Only in .: zzzqqqzzzqqq



------=_NextPart_000_afb_12ee_41ee
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_afb_12ee_41ee--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019