delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/08/24/05:00:23

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEBE0385DC28
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1692867621;
bh=BV45gWVXGT+CJVAhO/8ih9K6DC+YRucZKVKE36/TjyY=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=Km0oDs5doOHGOkqKAIiubfy0DA+WxjnlhVQQWl4SrfCQJnM2lGt0dm3pe1VxEjNqt
bGAFQxTlDme2HqOFgCIrd7QyF31r1xjDwxPOsYKOx064nOVSPwdwGdEnuikY5xXK1l
Q2IlB9VRKZqoMsy4PZkjmS/D0LhlrETIcbLzvaV8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10AB3385DC03
Date: Thu, 24 Aug 2023 10:59:33 +0200
To: cygwin AT cygwin DOT com
Subject: Re: scp stalls on uploading in cygwin 3.5 current master.
Message-ID: <ZOcb9SKtMPTQfj/m@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20230824060502 DOT c4798062cb19d4d35a5633ae AT nifty DOT ne DOT jp>
<20230824123131 DOT 390b4471915c963425c77608 AT nifty DOT ne DOT jp>
MIME-Version: 1.0
In-Reply-To: <20230824123131.390b4471915c963425c77608@nifty.ne.jp>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Aug 24 12:31, Takashi Yano via Cygwin wrote:
> On Thu, 24 Aug 2023 06:05:02 +0900
> Takashi Yano wrote:
> > Hi Corinna,
> > 
> > After the commit dedbbd74d0a8, "scp file server:." stalls.
> > I confirmed this when the "server" is a Linux machine.
> > The problem does not occur if it is reverted.
> > 
> > Could you please have a look?
> > 
> > commit dedbbd74d0a8f3b7dfae6188321703a47bb8a2b3
> > Author: Corinna Vinschen <corinna AT vinschen DOT de>
> > Date:   Tue Aug 1 14:22:55 2023 +0200
> > 
> >     Cygwin: select: workaround FD_WRITE network event handling
> >     
> >     The FD_WRITE event is a false friend.  It indicates ready to write
> >     even if the next send fails with WSAEWOULDBLOCK.  *After* the fact,
> >     FD_WRITE will be cleared until sending is again possible, but that
> >     is too late for a select/write loop.
> >     
> >     Workaround that by using the WinSock select function when peeking
> >     at a socket and FD_WRITE gets indicated. WinSock select fortunately
> >     indicates writability correctly.
> >     
> >     Fixes: 70e476d27be8 ("(peek_socket): Use event handling for peeking socket.")
> >     Signed-off-by: Corinna Vinschen <corinna AT vinschen DOT de>
> 
> I'm not sure why at all, however, the following patch seems to
> solve the issue.
> 
> diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
> index 7b9473849..de5794c9f 100644
> --- a/winsup/cygwin/select.cc
> +++ b/winsup/cygwin/select.cc
> @@ -1790,7 +1790,7 @@ peek_socket (select_record *me, bool)
>        if (events & FD_WRITE)
>  	{
>  	  wfd_set w = { 1, { fh->get_socket () } };
> -	  TIMEVAL t = { 0 };
> +	  TIMEVAL t = { .tv_sec = 0, .tv_usec = 1 };
>  
>  	  if (_win32_select (0, NULL, &w, NULL, &t) == 0)
>  	    events &= ~FD_WRITE;

Yeah, this is weird. A TIMEVAL value of 0 indicates non-blocking,
so why should waiting a usec make that better?  It also potentially
slows down Cygwin's select noticably if multiple sockets are part
of the descriptor set.

Hmmm.

Is it possible that _win32_select returns with SOCKET_ERROR for 
some reason?

Unfortunately I'm a bit swamped ATM, but rather than setting t to 1
usec, what if the check goes:

  if (_win32_select (0, NULL, &w, NULL, &t) != 1)

?


Thanks,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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