This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Fix condition in select which results in busy loop.
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 6 Jun 2016 14:48:50 -0000
- Subject: [newlib-cygwin] Fix condition in select which results in busy loop.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=83834110a0279c228c5c7e232a5d7ce01dd04d3e
commit 83834110a0279c228c5c7e232a5d7ce01dd04d3e
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Mon Jun 6 16:18:53 2016 +0200
Fix condition in select which results in busy loop.
The check for current timestamp > start timestamp has an unwelcome
side effect: The loop is not left as long as the current timestamp
hasn't been incremented. This leads to busy loops of about one tick
(10 to 16 ms per MSDN).
This fixes https://cygwin.com/ml/cygwin/2016-05/msg00327.html
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/select.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index c63eaef..69391d8 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -211,7 +211,7 @@ select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
{
select_printf ("recalculating us");
LONGLONG now = gtod.usecs ();
- if (now > (start_time + us))
+ if (now >= (start_time + us))
{
select_printf ("timed out after verification");
/* Set descriptor bits to zero per POSIX. */