From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by sourceware.org (Postfix) with ESMTPS id 73FF93858413 for ; Wed, 15 Sep 2021 12:20:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 73FF93858413 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 (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MtOOm-1mljO30pGY-00uqTN for ; Wed, 15 Sep 2021 14:20:49 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id BAC8EA80D67; Wed, 15 Sep 2021 14:20:48 +0200 (CEST) Date: Wed, 15 Sep 2021 14:20:48 +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: <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> <20210915205433.014102a9c1204687135e1417@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210915205433.014102a9c1204687135e1417@nifty.ne.jp> X-Provags-ID: V03:K1:aqtb/mI7eKLv36bPuTH09vG6ArmOTv4PZYvmWLpChGiPg4zg2Qo WfwK2gxtQj+MJqOdVV3r9QHfNdOSsiAZTHi3aa4Wu0wvkrBlSaLmWif4vki8JQ4r5b7ImuC /vZH7cOtenoP+R9wE2C04JraSTDXEP5gIUOkKk7kkYLIOYyCsukEYMc+nkbL0yybIIl5mN8 V2ZNr9vaBgrDMp1XcN6ww== X-UI-Out-Filterresults: notjunk:1;V03:K0:OYWAMqkA3Zc=:h4Xf4LPBIuRR0EAlzd5YCb 66rmRaOeXNQiA6zcO9t/osIqA2ug0Y1NCPf5EznskrYjJhAQ2nEVL1g6/HnC6PlzycpBZ8Z22 z7DGVlkx89QLrHjbCnZhFA9miiEV5Zy3fynGbIUJuDguUmbmqLkB8HaW+gXTBTfkJFZafEouK 5BJUgh0nz6A3LQfIoc5N7rZMY6KD74YC6/VBpD/qWLRD6rBKmBpN0bze54jAfnTVc1OYKGEyf w8tt08aiHoEAHFrqGZnSOS2lSJ8SH/gKLAMWeaEVTOnyguX5Iyi4fp6a/qGDeEb5GAJ5F4Ole yhmVZY9nr2QinwqBfVMp1ivDyqdKbEtIUNKzgN5L3EwCv0lfJUqtGu9pPWJY/K7tR+ZQaJSRN ooWo+KWCA/W+63pxPYVd4k8aodmPzDu0qdPk02lsK0UkX8F3R6dqcJF2qREYSwZfyDWENOA3z e1iXiDE6eOy7zG7YbBPAqlPtvknVZfEPiggLg1oRiE82HLiJ7hllQIBq6upPlDsRBogDeBXF2 lT954OQggjQPQ3tTIeElWusujH7NzMSMQuig7LT+WHw0pZBIjKQctzfCKShnidquXge1NO6kj yLk34PJdVWg48TCPekFmw4+pmCKSN1AuH+D4PvntX5OxuQkGmgSpCXP6eKR7NGdpFGuJqCf0t 324MvVi1+luiR1OWg8o4v3VEbCqWkRLnzMBDc2sYA40H+ykhAR19UUuqjsgSRzdDfvgXnFBjy vTha/EH6aDxLeunLCTJ9qSYuxuVnMNaC+MA3WrwMqNlylGHpnuj+5/BUzU0= X-Spam-Status: No, score=-105.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 12:20:52 -0000 On Sep 15 20:54, Takashi Yano wrote: > This shoudl be: > > @@ -652,11 +652,17 @@ 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; > + } > + else if (GetLastError () == ERROR_BROKEN_PIPE) > + return -1; > } > if (fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE) > return -1; After Ken's comment, I was going to suggest this one: >From 34b14470406cb9551f98707bf63175811a506523 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 15 Sep 2021 14:17:59 +0200 Subject: [PATCH] Cygwin: pipes: don't call NtQueryInformationFile on read side of pipes NtQueryInformationFile hangs if it's called on the read side handle of a pipe while another thread or process is performing a blocking read. Avoid select potentially hanging by calling NtQueryInformationFile only on the write side of the pipe and using PeekNamedPipe otherwise. --- winsup/cygwin/select.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index a09d8a34da2e..566cf66d653b 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -587,6 +587,14 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *) static int pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing) { + if (fh->get_device () == FH_PIPER) + { + DWORD nbytes_in_pipe; + if (!writing && PeekNamedPipe (h, NULL, 0, NULL, &nbytes_in_pipe, NULL)) + return nbytes_in_pipe > 0; + return -1; + } + IO_STATUS_BLOCK iosb = {{0}, 0}; FILE_PIPE_LOCAL_INFORMATION fpli = {0}; NTSTATUS status; -- 2.31.1