[grilo] net: Initialize GTimeVal for throttling



commit b4dca1129989f9d9fc4a274860d38566802cd11c
Author: Victor Toso <me victortoso com>
Date:   Sat Jul 30 18:22:51 2016 +0200

    net: Initialize GTimeVal for throttling
    
    The last_request variable was never initialized leading to delay
    between request to not work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769331

 libs/net/grl-net-wc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index ed3f0ba..8ed4dc2 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -762,12 +762,14 @@ get_url (GrlNetWc *self,
 
   if ((now.tv_sec - priv->last_request.tv_sec) > priv->throttling
           || is_mocked()) {
+    priv->last_request = now;
     id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
                           get_url_cb, c, request_clos_destroy);
   } else {
-    GRL_DEBUG ("delaying web request");
-
     priv->last_request.tv_sec += priv->throttling;
+
+    GRL_DEBUG ("delaying web request by %lu seconds",
+               priv->last_request.tv_sec - now.tv_sec);
     id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
                                      priv->last_request.tv_sec - now.tv_sec,
                                      get_url_cb, c, request_clos_destroy);


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