[Spice-devel] Actually process write watches in the wakeup handler

Submitted by Jeremy White on June 3, 2012, 3:28 p.m.

Details

Message ID 4FCB8285.5070502@codeweavers.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Jeremy White June 3, 2012, 3:28 p.m.
My apologies for the churn; this is, I think, a slightly better patch than
my previous patch, 'Process watches even when there is no X activity', in that
it avoids doing an extra polling select when we're idle.

---
 src/spiceqxl_main_loop.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/spiceqxl_main_loop.c b/src/spiceqxl_main_loop.c
index 1718861..e57fb91 100644
--- a/src/spiceqxl_main_loop.c
+++ b/src/spiceqxl_main_loop.c
@@ -315,9 +315,24 @@  static void select_and_check_watches(void)
     }
 }
 
+static int no_write_watches(Ring *w)
+{
+    SpiceWatch *watch;
+    RingItem *link;
+    RingItem *next;
+
+    RING_FOREACH_SAFE(link, next, w) {
+        watch = (SpiceWatch*)link;
+        if (!watch->remove && (watch->event_mask & SPICE_WATCH_EVENT_WRITE))
+            return 0;
+    }
+
+    return 1;
+}
+
 static void xspice_wakeup_handler(pointer data, int nfds, pointer readmask)
 {
-    if (!nfds) {
+    if (!nfds && no_write_watches(&watches)) {
         return;
     }
     select_and_check_watches();

Comments

On Sun, Jun 03, 2012 at 10:28:05AM -0500, Jeremy White wrote:
> My apologies for the churn; this is, I think, a slightly better patch than
> my previous patch, 'Process watches even when there is no X activity', in that
> it avoids doing an extra polling select when we're idle.

Pushed this version, thanks. I saw the thread on x-org has no
development so far, but thanks for writing it.

> 
> ---
>  src/spiceqxl_main_loop.c |   17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/spiceqxl_main_loop.c b/src/spiceqxl_main_loop.c
> index 1718861..e57fb91 100644
> --- a/src/spiceqxl_main_loop.c
> +++ b/src/spiceqxl_main_loop.c
> @@ -315,9 +315,24 @@ static void select_and_check_watches(void)
>      }
>  }
>  
> +static int no_write_watches(Ring *w)
> +{
> +    SpiceWatch *watch;
> +    RingItem *link;
> +    RingItem *next;
> +
> +    RING_FOREACH_SAFE(link, next, w) {
> +        watch = (SpiceWatch*)link;
> +        if (!watch->remove && (watch->event_mask & SPICE_WATCH_EVENT_WRITE))
> +            return 0;
> +    }
> +
> +    return 1;
> +}
> +
>  static void xspice_wakeup_handler(pointer data, int nfds, pointer readmask)
>  {
> -    if (!nfds) {
> +    if (!nfds && no_write_watches(&watches)) {
>          return;
>      }
>      select_and_check_watches();
> -- 
> 1.7.9.5
> 

> ---
>  src/spiceqxl_main_loop.c |   17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/spiceqxl_main_loop.c b/src/spiceqxl_main_loop.c
> index 1718861..e57fb91 100644
> --- a/src/spiceqxl_main_loop.c
> +++ b/src/spiceqxl_main_loop.c
> @@ -315,9 +315,24 @@ static void select_and_check_watches(void)
>      }
>  }
>  
> +static int no_write_watches(Ring *w)
> +{
> +    SpiceWatch *watch;
> +    RingItem *link;
> +    RingItem *next;
> +
> +    RING_FOREACH_SAFE(link, next, w) {
> +        watch = (SpiceWatch*)link;
> +        if (!watch->remove && (watch->event_mask & SPICE_WATCH_EVENT_WRITE))
> +            return 0;
> +    }
> +
> +    return 1;
> +}
> +
>  static void xspice_wakeup_handler(pointer data, int nfds, pointer readmask)
>  {
> -    if (!nfds) {
> +    if (!nfds && no_write_watches(&watches)) {
>          return;
>      }
>      select_and_check_watches();
> -- 
> 1.7.9.5
> 

> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel