[grilo] net: Check for throttling only if set



commit ca91b2823643aa963837776a82147693e448c6cc
Author: Victor Toso <me victortoso com>
Date:   Thu Sep 15 17:36:26 2016 +0200

    net: Check for throttling only if set
    
    Otherwise, we might add several 0 seconds delay on multiple fetch
    requests leading to unexpected behavior (assertion)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771338

 libs/net/grl-net-wc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index 8ed4dc2..8d7c186 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -760,8 +760,11 @@ get_url (GrlNetWc *self,
 
   g_get_current_time (&now);
 
-  if ((now.tv_sec - priv->last_request.tv_sec) > priv->throttling
-          || is_mocked()) {
+  /* If grl-net-wc is not mocked, we need to check if throttling is set
+   * otherwise the throttling delay check would always be true */
+  if (is_mocked ()
+      || priv->throttling == 0
+      || (now.tv_sec - priv->last_request.tv_sec) > priv->throttling) {
     priv->last_request = now;
     id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
                           get_url_cb, c, request_clos_destroy);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]