All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: qemu-devel@nongnu.org, stefanha@redhat.com, famz@redhat.com
Cc: alistair.francis@xilinx.com, alistair23@gmail.com,
	edgar.iglesias@xilinx.com, qemu-block@nongnu.org
Subject: [Qemu-devel] [RFC v1 4/4] util/oslib-win32: Recursivly pass the timeout
Date: Tue, 27 Jun 2017 16:57:49 -0700	[thread overview]
Message-ID: <4b48ca3f3c45bee1103bcb50d87e6d5cadc88d6f.1498607452.git.alistair.francis@xilinx.com> (raw)
In-Reply-To: <cover.1498607452.git.alistair.francis@xilinx.com>

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---

 util/oslib-win32.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index a015e1ac96..3630e46499 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -432,10 +432,10 @@ static int poll_rest(gboolean poll_msgs, HANDLE *handles, gint nhandles,
             }
         }
 
-        /* If no timeout and polling several handles, recurse to poll
-         * the rest of them.
+        /* We only found one and we are waiting on more then one. Let's try
+         * again.
          */
-        if (timeout == 0 && nhandles > 1) {
+        if (nhandles > 1) {
             /* Remove the handle that fired */
             int i;
             if ((ready - WAIT_OBJECT_0) < nhandles - 1) {
@@ -444,7 +444,20 @@ static int poll_rest(gboolean poll_msgs, HANDLE *handles, gint nhandles,
                 }
             }
             nhandles--;
-            recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0);
+
+            /* If we just had a very small timeout let's increase it when we
+             * recurse to ensure we don't just busy wait. This ensures we let
+             * the Windows threads block at least a little. If we previously
+             * had some wait let's set it to zero to avoid blocking for too
+             * long.
+             */
+            if (timeout < 10) {
+                timeout = timeout + 1;
+            } else {
+                timeout = 0;
+            }
+            recursed_result = poll_rest(FALSE, handles, nhandles, fds,
+                                        nfds, timeout);
             return (recursed_result == -1) ? -1 : 1 + recursed_result;
         }
         return 1;
-- 
2.11.0

  parent reply	other threads:[~2017-06-28  0:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 23:57 [Qemu-devel] [RFC v1 0/4] Windows runtime improvements Alistair Francis
2017-06-27 23:57 ` [Qemu-devel] [RFC v1 1/4] util/aio-win32: Only select on what we are actually waiting for Alistair Francis
2017-06-29  9:18   ` Fam Zheng
2017-06-29 12:22   ` Paolo Bonzini
2017-06-27 23:57 ` [Qemu-devel] [RFC v1 2/4] util/oslib-win32: Remove invalid check Alistair Francis
2017-06-28  4:12   ` Philippe Mathieu-Daudé
2017-06-29  9:25   ` Fam Zheng
2017-06-29 13:32   ` Paolo Bonzini
2017-06-29 16:37     ` Alistair Francis
2017-06-30 10:37       ` Paolo Bonzini
2017-07-05 15:44         ` Alistair Francis
2017-06-27 23:57 ` [Qemu-devel] [RFC v1 3/4] util/oslib-win32: Fix up if conditional Alistair Francis
2017-06-29  9:34   ` Fam Zheng
2017-06-29 12:25   ` Paolo Bonzini
2017-06-29 16:31     ` Alistair Francis
2017-06-27 23:57 ` Alistair Francis [this message]
2017-06-29  9:38   ` [Qemu-devel] [RFC v1 4/4] util/oslib-win32: Recursivly pass the timeout Fam Zheng
2017-06-29 12:34   ` Paolo Bonzini
2017-06-29 16:33     ` Alistair Francis
2017-06-29 19:47       ` Paolo Bonzini
2017-06-29 21:17         ` Alistair Francis
2017-07-06 23:48 ` [Qemu-devel] [RFC v1 0/4] Windows runtime improvements no-reply
2017-07-07  0:05   ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b48ca3f3c45bee1103bcb50d87e6d5cadc88d6f.1498607452.git.alistair.francis@xilinx.com \
    --to=alistair.francis@xilinx.com \
    --cc=alistair23@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=famz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.