[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RFC v1 4/4] util/oslib-win32: Recursivly pass the time
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [RFC v1 4/4] util/oslib-win32: Recursivly pass the timeout |
Date: |
Thu, 29 Jun 2017 17:38:50 +0800 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Tue, 06/27 16:57, Alistair Francis wrote:
> Signed-off-by: Alistair Francis <address@hidden>
> Acked-by: Edgar E. Iglesias <address@hidden>
> ---
>
> 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
>
This is a hack, can we fix what is the causing the busy wait instead?
Fam
- [Qemu-block] [RFC v1 3/4] util/oslib-win32: Fix up if conditional, (continued)
[Qemu-block] [RFC v1 1/4] util/aio-win32: Only select on what we are actually waiting for, Alistair Francis, 2017/06/27