delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/07/01/15:51:11

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD67A38618AF
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1593633032;
bh=Weo+M4HGGfwdwIUUrKnUe1nSe6MVC0C6tgshq+ufJPk=;
h=Date:From:To:Subject:References:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
Reply-To:From;
b=A2gfHuX8L/43O5aTbxxNckWAIcLeNfTDTDGFLgmtzVEnwL0xlAmlEu6cSgCC+E682
MPAASRZBUEMeIK6oI1ylSs1fU3oGCJhIHPFw3piRLjxLGzlUAIorfjlhQgPz1DWjhs
lpyJeAtxQ2LXLNbw8ENbJ0KqCJXAXrEy1OMsnZhM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 602AC3857007
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=cygwin.com
Authentication-Results: sourceware.org;
spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com
Date: Wed, 1 Jul 2020 21:50:27 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: TCP_KEEPINVTL and TCP_KEEPIDLE - Socket Keep Alives not working
Message-ID: <20200701195027.GL3499@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAEF1h+WHsGXzSykQ0G3aXG=8jY5VmpYQQiYNP7DjHJTS1Bkpsw AT mail DOT gmail DOT com>
<ba71f855-276d-9d45-5c78-6d0a91dc57dd AT cornell DOT edu>
<CAEF1h+UuQmXz-ntG6YMed+DKFgikJT_aJN5Hu94ZnZ8_LGxMjQ AT mail DOT gmail DOT com>
<20200630111215 DOT GE3499 AT calimero DOT vinschen DOT de>
<CAEF1h+Xm_KbsdyU2EUiCef8WAnDLn=avaNGC07uniYbgeT-GwQ AT mail DOT gmail DOT com>
<20200630165358 DOT GG3499 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20200630165358.GG3499@calimero.vinschen.de>
X-Provags-ID: V03:K1:IU8qrUkMYDlPPTfQwTyEWIqAaaDqtpRgvN+rALSnMTRM0OxKhr5
lLGCw+RvEWDytu5NMwvQ/v/INoHE/VruYwp2W2hT2iwz9Q4Sl0SfH3HXDRPNyIWVsaC67HY
u5/SK8u++cDP4yyIif1tlW6qCHmodDfmLmeRkdsnK1wQUzhvAW6n+MEUXElxSGwyaHXghD9
pLk2lz1MgXX6XTTW8IrBg==
X-UI-Out-Filterresults: notjunk:1;V03:K0:gm/zpnEiePo=:Gxa5NpKtDUhRvnnZOXRVaQ
vHr0NOLLN5pkB16HwTBJ6LAti/chKPdGzIjQNlLLd4tEJv66Onbzvsu7WCxKjOwbbEimNujgt
HhfwBSV4RxRYWYZpHJDBQm8RT10OUrsYfVGXFIRaJM9np2comTBrRh2E17sgXynv6A1I4ANiG
nhAtZSdXDhT+gnIvKzSRttueX55ELc25cAcMlgKr69fQJfxNqjJPRAQkGxM2uoU6uXde1uC7o
BZI2+cTU1b5dR7jychCcFJuUWUogpxB7NihKJWvGbdK02Ht45TaXnx/5Qi23XKHKwLlQNYM3/
ZfTHQRNPZLXyFzMUa/P33iNP4+4YiCHSdV9GTUcoU4htObe+6hH7oZMGfC/kokGcYCBTAdV9p
UOk3SLk3Ma/aJi4BzdH/XqZI2+ZIkv+VeOOgNPXOaCb5ZBhI8vVCQUfVAJg1YbkVFWQznUWjr
ECchPS2tjE+A7n6GU0vR+M+euHjwRCCUlF6thzCl166NdCdZ7twb0pPbMXvKyYj03dSUcQJFf
B4dEYA9LFI1g30nh+wawnj/hzArmo44jSCU+Q3oZJNlYK+RXNniKk2K2+SiYFjpwd/vPs6WCp
WwG1UuvO2TAUQ12BAWmW4OQoFblbGqfMsir/natmFbv9n1EIqeGLu3XFxRH4qAHQLo9+pfCCP
mnFXVh6Impb5RQ32Hj0/PlbomCoZBMm18D4UP6ThYbXZGl559XPE+ITiIxCGR6mvteLcqCrLT
5hXZQW80/DSniLOob09fOHLSkDIt8zEjKuf5a/GFm7KPG3Nb7eHel5FkoE3x/LU8u8GqmsIBy
9PzbKNIWsfUaaV54XJWWCC5dvPyJIMmvMzOZI0bIcc6FEyoEps5ezOQuIBrQKU59tcjgFoO
X-Spam-Status: No, score=-99.0 required=5.0 tests=BAYES_00,
GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE,
RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
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: <http://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: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

On Jun 30 18:53, Corinna Vinschen wrote:
> On Jun 30 09:46, Cary Lewis via Cygwin wrote:
> > Thanks for the reply. The answer to your question is that the 2 hour keep
> > alive was not sufficient for a particular use case I encountered.
> > 
> > I was trying to use curl under cygwin to access a very slow REST endpoint
> > that was taking up to 8 minutes to generate download before any data flowed
> > back to the client. This caused the server to abort the socket.
> > 
> > Accessing the endpoint in chrome or firefox revealed that they set a
> > keepalive to 45 seconds, which kept the server happy.
> > 
> > Attempting to set --keepalive-time=45 in cygwin's curl didn't work, and
> > wireshark revealed that no keepalives were being sent.
> > 
> > I will attempt to patch cygwin, I got the build to work. Can you point me
> > in the right direction, in terms of where the socket calls get mapped to
> > the winsock calls?
> 
> Actually, while I'm usually happy to take contributions, you don't have
> to dig into that yourself.  I already have a few local patches in the
> loop changing some of the affected code.  I have a good idea what's
> required to add the keep-alive socket options to that code, so just lay
> back and stay tuned for now.

Ok, so I added support for a couple more IPPROTO_TCP socket options.
First of all I fixed TCP_MAXSEG which was using the BSD value, rather
than the WinSock value.  Then I added TCP_FASTOPEN, TCP_KEEPIDLE,
TCP_KEEPCNT, TCP_KEEPINTVL, TCP_QUICKACK and TCP_USER_TIMEOUT:

- TCP_FASTOPEN is supported since W10 1607, it's just faked on older
  systems.

- TCP_KEEPIDLE, TCP_KEEPCNT, TCP_KEEPINTVL are using the options
  of the same name since W10 1709, WSAIoctl(SIO_KEEPALIVE_VALS)
  on older systems.

  But here's a problem: Older systems didn't allow to change
  TCP_KEEPCNT.  It is always fixed to 10.  Mulling over that problem in
  the shower, I came up with the following solution:

  The max keep-alive timeout is TCP_KEEPIDLE + TCP_KEEPCNT * TCP_KEEPINTVL.
  This should stay the same from a user space perspective.  So the current
  code tweaks the TCP_KEEPINTVL given to WinSock so that

  TCP_KEEPCNT * user space TCP_KEEPINTVL == 10 * WinSock TCP_KEEPINTVL

  Example: user space TCP_KEEPCNT 4, TCP_KEEPINTVL 5   (4 * 5 == 20)
  ==>      WinSock    TCP_KEEPCNT 10, TCP_KEEPINTVL 2  (10 * 2 == 20)

  I hope that makes sense.

- TCP_USER_TIMEOUT is supported with msec granularity since W10 1607
  (called TCP_MAXRTMS), with 1 secs granularity on older systems
  (called TCP_MAXRT).  Use the latter on older systems under the expected
  loss of precision.

- TCP_QUICKACK is supposedly supported on Windows as a socket option
  but it's still not clear if the net got that right so far.  However,
  there's WSAIoctl(SIO_TCP_SET_ACK_FREQUENCY) doing the same.

I uploaded developer snapshots to https://cygwin.com/snapshots/,
please test.

For testing, you'll need at least the DLL, plus the changed headers
cygwin/socket.h and netinet/tcp.h from the complete tar file
cygwin-20200701.tar.xz. Or, just take the DLL and fetch the headers
right from the git repo.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
--
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