From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by sourceware.org (Postfix) with ESMTPS id 3BD673858C3B for ; Wed, 15 Sep 2021 11:13:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3BD673858C3B Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Movrq-1nGb7o33Jm-00qUIc for ; Wed, 15 Sep 2021 13:13:26 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id EB07EA80D6A; Wed, 15 Sep 2021 13:13:25 +0200 (CEST) Date: Wed, 15 Sep 2021 13:13:25 +0200 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? Message-ID: Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <20210914185623.0488635bf6d1e925baee5fe8@nifty.ne.jp> <20210914191924.5092f63762d62c88431b5313@nifty.ne.jp> <20210914210507.be6c950c948033704542bc42@nifty.ne.jp> <20210915092100.796985ae33039f3184483450@nifty.ne.jp> <20210915094454.42ef1d085d9bf92a1af8d39a@nifty.ne.jp> <20210915095911.415d174ea38fb2d2ea8e5432@nifty.ne.jp> <20210915194858.845bcd54c0c63246b40703a8@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210915194858.845bcd54c0c63246b40703a8@nifty.ne.jp> X-Provags-ID: V03:K1:O8ftLI/F+W3DZlKbqu+LYTNAiTfMrgFiU1gnh/jCUcDYqvu4g68 57/zBPdUuEq9ZARHrQDDnI9rI+oQEwNW2YybXieM4WJaGVaPtsal2tJ7EZ2BOZUEeo+CBKh X3ejorjA1CvP7AdItV0+k9LB8/pg5k5otC2dMzJ+QKbx4pZNIVSON7OTKtHjmCD6p4z8lCj 8/TvsqqtCZ5sqHHwbeVBQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:nsNbrN1h46E=:HG/MKw2oiix1lBniCmEcX3 XfYPRP+WkCA6G+hnpZbHQFV/MKKct0PlyHes95DEJEnh22JFVr4DW57cxQP+h2IFsWhz5tXZn pVBZiD8olSjpQuCejS5+T9Wr7IyTU7GFS/GlrhlqZLEaWSOBQ7z//wcYmbuip6xYohQWcShaw /lii75+PZrNGnRJWnO1w+KHark2EWMLdpi97kkPkaxADOB16m2PODdoe3I/iHCQ7C/SIKzTRj wd7HrRMMPuORSuXs2mjlIZNN9ZFKB0V3b5aeBA8cmhtPJzqlqs6mvLqwwvUCEMQXhmk4Vctzp +hjNIbgmDKgHmayJkyzu1WCxXoiwMuDMJKOGp28iODxjFNJsTTnyf8/ZxN9H5ZfXZWlNk9f7d z9Uzb9w0TNYz3n/LXI3ySkZhES4Peje8dur9NUsHnZGUj0mO34RVJ917fHpS2sGrFdXTe+OCT jUhrmDAmnOkbp59f5YAxiFs4EcLEd+Ot8aNtvQ9n6rlSZMA5A0Gh7fHeK5+09QASrkMRfihVh c4ZFsTVctIN7ib9WTt1HkEbt+xi9HOlhsBc53JVtTo9PyQfyiaca3xd4JZfzhsgYNgTbqrt20 PP7ljduFjqQIPVtFDHyY2F1pkxmSLuw9a70y9AQph0SeluEn+BuGEkBABEAPYkvz/DpYrwjb4 vWiqp58xXh4vhyzZ2F/FKFiFK4JogjgGYNVbwsi4Jkm6g45+GWQOPviBgRcg0WidlCFXnnLNL Q0lw3BxWlm8OO04oU56xPOG00uNTLwl9OPjtosHl7xmQEZl+y8gklaOYA64= X-Spam-Status: No, score=-105.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 11:13:29 -0000 On Sep 15 19:48, Takashi Yano wrote: > On Wed, 15 Sep 2021 11:57:44 +0200 > Corinna Vinschen wrote: > > ...but we're unconditionally using NtQueryInformationFile at the start > > of pipe_data_available. If this is the read side of the pipe, isn't > > there a chance that another (non-Cygwin) process is performing a blocking > > read and this call will hang? > > I will check that. Something like that comes to mind: diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index fd23122988c3..cf9ad87538f2 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -594,18 +594,6 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing) if (fh->has_ongoing_io ()) return 0; - status = NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), - FilePipeLocalInformation); - if (!NT_SUCCESS (status)) - { - /* If NtQueryInformationFile fails, optimistically assume the - pipe is writable. This could happen if we somehow - inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES - access on the write end. */ - select_printf ("fd %d, %s, NtQueryInformationFile failed, status %y", - fd, fh->get_name (), status); - return writing ? 1 : -1; - } if (writing) { /* If there is anything available in the pipe buffer then signal @@ -633,6 +621,18 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing) /* Note: Do not use NtQueryInformationFile() for query_hdl because NtQueryInformationFile() seems to interfere with reading pipes in non-cygwin apps. Instead, use PeekNamedPipe() here. */ + status = NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), + FilePipeLocalInformation); + if (!NT_SUCCESS (status)) + { + /* If NtQueryInformationFile fails, optimistically assume the + pipe is writable. This could happen if we somehow + inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES + access on the write end. */ + select_printf ("fd %d, %s, NtQueryInformationFile failed, status %y", + fd, fh->get_name (), status); + return 1; + } if (fh->get_device () == FH_PIPEW && fpli.WriteQuotaAvailable == 0) { HANDLE query_hdl = ((fhandler_pipe *) fh)->get_query_handle (); @@ -652,11 +652,15 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing) } /* TODO: Buffer really full or non-Cygwin reader? */ } - else if (fpli.ReadDataAvailable) + else { - paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (), - fpli.ReadDataAvailable); - return 1; + DWORD nbytes_in_pipe; + if (PeekNamedPipe (h, NULL, 0, NULL, &nbytes_in_pipe, NULL)) + { + paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (), + nbytes_in_pipe); + return nbytes_in_pipe > 0; + } } if (fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE) return -1; Corinna