delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/08/25/09:19:24

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 943AA3858C2D
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1692969562;
bh=mTRcqyku0FAlDlTq5KOMD0ZMABuV+2kFt0qj7rA1Tdw=;
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=o97YnmqOO9IU2VQeIc8wjZVu1ppgZqy/kEbdJ/3UaWdIkJiP4TwSpmplz/wFxl9zX
CF4z1Euq8zP3YdYas56oo9gaiwU60IH9tBj2tKAeZdKzTDko1oDaAYvIGgx1j2UVrh
WsrjK+gpcw+XreQowm2HmdxhOW6CFblzQHD/CMWU=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7A133858C53
Date: Fri, 25 Aug 2023 15:19:03 +0200
To: cygwin AT cygwin DOT com
Subject: Re: [EXTERNAL] Re: scp stalls on uploading in cygwin 3.5 current
master.
Message-ID: <ZOiqR14RTnRudWP7@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>
<ZOcb9SKtMPTQfj/m AT calimero DOT vinschen DOT de>
<20230825174832 DOT 9ebae8112667d5d5411cb8db AT nifty DOT ne DOT jp>
<ZOiHkCWY7PK3livD AT calimero DOT vinschen DOT de>
<DM8PR09MB70957918F669340C497F48D5A5E3A AT DM8PR09MB7095 DOT namprd09 DOT prod DOT outlook DOT com>
<ZOidNPZSXvaecVJc AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <ZOidNPZSXvaecVJc@calimero.vinschen.de>
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 25 14:23, Corinna Vinschen via Cygwin wrote:
> On Aug 25 12:08, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
> > > I don't have an answer to this problem yet.
> > > 
> > > Can we use send(sock, "", 0) to reenable FD_WRITE, perhaps?
> > 
> > Can't it just be assumed that the socket is _always_ writeable _unless_ the last send() failed?
> > In other words, try to always send() if it did not fail before.  If it did, only send() after
> > FD_WRITE was returned in the event mask.
> 
> You're looking from the application perspective, but as the underlying
> library we don't have the application under control.  The application
> can rightfully expect POSIX-like behaviour from select(2), and *that*
> means, it can expect select(2) to return a socket as non-writable if the
> internal buffer is full, *before* it calls send:
> 
>   while (...)
>     {
>       /* send as long as we can, otherwise do another job in the meantime */
>       while (select (..., <zero timeout>))
> 	send (<blocking>);
>       <do something else>
>     }

No, wait.

I just realized that this isn't correct.  While select indicates that
data can be written, it doesn't indicate how much data can be written.
I. e., if select returns, and there's only buffer space for 10 bytes,
and the send call tries to send 100 bytes, it *will* block, unless the
socket is non-blocking and returns EAGAIN.

The testcase my patch was based on called a poll/write loop on a
socketpair without changing the socket to non-blocking before.  At the
time I didn't even realize that it's actually not a good test, d'oh.


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