From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id 3D09C388F078; Mon, 11 May 2020 13:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D09C388F078 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: FIFO: improve the interruptibility of raw_read X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: 1f273459473e8a5a7e8b32da8e4b88c16841bd8c X-Git-Newrev: e637d5361782f0bb911f62355a331aa6098b0058 Message-Id: <20200511135547.3D09C388F078@sourceware.org> Date: Mon, 11 May 2020 13:55:47 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2020 13:55:47 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e637d5361782f0bb911f62355a331aa6098b0058 commit e637d5361782f0bb911f62355a331aa6098b0058 Author: Ken Brown Date: Mon May 11 09:03:37 2020 -0400 Cygwin: FIFO: improve the interruptibility of raw_read During a blocking read, we sleep for 1 ms after each iteration through the connected writers. Currently we do this by calling Sleep (1). Remove this call to Sleep and instead change the timeout in the cygwait call from 0 to 1, so that raw_read can be interrupted while sleeping. Diff: --- winsup/cygwin/fhandler_fifo.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 9cc00d5e7..e8a05dfbf 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -1335,8 +1335,8 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len) } else { - /* Allow interruption. */ - DWORD waitret = cygwait (NULL, cw_nowait, cw_cancel | cw_sig_eintr); + /* Allow interruption and don't hog the CPU. */ + DWORD waitret = cygwait (NULL, 1, cw_cancel | cw_sig_eintr); if (waitret == WAIT_CANCELED) pthread::static_cancel_self (); else if (waitret == WAIT_SIGNALED) @@ -1356,8 +1356,6 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len) set_errno (EBADF); goto errout; } - /* Don't hog the CPU. */ - Sleep (1); } errout: len = (size_t) -1;