From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 080413858D34 for ; Thu, 2 Jul 2020 14:53:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 080413858D34 Received: by mail-lj1-x22b.google.com with SMTP id n23so32596359ljh.7 for ; Thu, 02 Jul 2020 07:53:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=VHOs/2jWmmDTIlf8JubhIUK7vk3XogBCL0NqxA4AVSs=; b=q2QXQXOzK4uhIOcGwnPaG0FiTqDTyfVB17//Fkbkse2kdKsnGArj8OnZ1tyYKBnfau 2nYv/SEUJGU+bzsFh+10+oN3QgBo95C5gl8TJO9mKMJwAuMrF4SZxYsKH7DRkoGoHZmU q/p2UibunxGmziMCWEVsxfo/MjXsW6peA8jsxcUQO1G/mb5D3pc9H401f7tgSDNey9kO agq0HapM/5QGxOMiXP6v+qn72JzhBcqaHHvb0zh1AmGvAkSiLnA4mDRBhzBhWFnyjpok PapmMnHoQwdIYCyqchIES6Nqahb44YYBuEkADDyqqa2ratrMXEfeHxlYZYMhUW5zzrLp X8qQ== X-Gm-Message-State: AOAM532szDtQbJ6Kwfs+K3WIYucmbVyhEp+fx1FIddKjMksJasfag+5x MgXZ1Fb58Uz2t8eJA06JXYRfbl5NHubMWW/q/HxV6kOfbpA1 X-Google-Smtp-Source: ABdhPJxpZdGhDxCe8vMsM7G0cGOA6nQKnCcHPgln/D96cD8393Oj5lNZQz5yXFi9y5dYYdCW9d9QiFI7I0WelSjE5mM= X-Received: by 2002:a2e:b892:: with SMTP id r18mr17474253ljp.319.1593701583141; Thu, 02 Jul 2020 07:53:03 -0700 (PDT) MIME-Version: 1.0 References: <20200630111215.GE3499@calimero.vinschen.de> <20200630165358.GG3499@calimero.vinschen.de> <20200701195027.GL3499@calimero.vinschen.de> In-Reply-To: <20200701195027.GL3499@calimero.vinschen.de> From: Cary Lewis Date: Thu, 2 Jul 2020 10:52:52 -0400 Message-ID: Subject: Re: TCP_KEEPINVTL and TCP_KEEPIDLE - Socket Keep Alives not working To: cygwin@cygwin.com X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 14:53:07 -0000 That's amazing, thanks. We'll have to try to recompile curl under cygwin to confirm that it keeps up the constants, and then does the right posix calls. I will grab the files, and try to have this tested and report back to you. Take care, Cary Lewis On Wed, Jul 1, 2020 at 3:51 PM Corinna Vinschen wrote: > 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 >