X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2A85385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1692991785; bh=HTFpaP4+1FsH2i7vy1lTUTlWMryUm3WkyH8rRVErEu8=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Tw7mv1nNZir+yNtbhWf9G+FwYopRM7KB/vY5cKiNyqgEfhOyafBi6hFUIfE6ZdPSI saM4TViq39ocAB9u+cOZGa58YwiAxtWEYPNqTb6igxb4rnjdSKqPEVFddf3ve7LOk1 akob2zcEc6iZqwz+ksf+MGHqixuZs8kSHOzrhM9w= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18F663858C62 Date: Sat, 26 Aug 2023 04:29:24 +0900 To: cygwin AT cygwin DOT com Subject: Re: scp stalls on uploading in cygwin 3.5 current master. Message-Id: <20230826042924.53b49a9f8372a9196a151425@nifty.ne.jp> In-Reply-To: References: <20230824060502 DOT c4798062cb19d4d35a5633ae AT nifty DOT ne DOT jp> <20230824123131 DOT 390b4471915c963425c77608 AT nifty DOT ne DOT jp> <20230825174832 DOT 9ebae8112667d5d5411cb8db AT nifty DOT ne DOT jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT 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: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Hi Corinna, On Fri, 25 Aug 2023 12:50:56 +0200 Corinna Vinschen wrote: > On Aug 25 17:48, Takashi Yano via Cygwin wrote: > > This did not help. I looked into this deeper and noticed that: > > 1) _win32_select() sometimes returns 0. > > 2) If _win32_select() returns 0, WaitForMultipleObjects(..., INFINITE) > > is called in thread_socket(). > > 3) WaitForMultipleObjects() sometimes does not return for FD_WRITE > > for unknown reason. > > This causes the stall. > > So the situation is that the network event handling returned FD_WRITE, > because it always returns FD_WRITE as long as a non-blocking send() > function didn't explicitely fail due to buffer overrun. > > However, _win32_select will notice that the buffer is full, so it > does not return 1, but 0. I e., the socket is not ready for writing. > > Now you're saying that it's possible that the following WFMO will > never return? > > That would mean that the FD_WRITE event won't be triggered again because > it already *had* been triggered and the only way to re-enable it is to > call one of the send() functions (see > https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaeventselect) > > I don't have an answer to this problem yet. > > Can we use send(sock, "", 0) to reenable FD_WRITE, perhaps? Your idea seems to work. The following patch looks to solve the issue. Is it supposed to be any side effect()? diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 7b9473849..443f95e68 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -1824,8 +1824,16 @@ thread_socket (void *arg) { for (select_record *s = si->start; (s = s->next); ) if (s->startup == start_thread_socket) - if (peek_socket (s, false)) - event = true; + { + if (peek_socket (s, false)) + event = true; + else if (s->write_selected) + { + /* Retrigger WSA socket event */ + fhandler_socket_wsock *fh = (fhandler_socket_wsock *) s->fh; + fh->write ("", 0); + } + } if (!event) for (int i = 0; i < si->num_w4; i += MAXIMUM_WAIT_OBJECTS) switch (WaitForMultipleObjects (MIN (si->num_w4 - i, -- Takashi Yano -- 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