summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <me@victortoso.com>2020-02-17 10:02:46 +0100
committerVictor Toso <me@victortoso.com>2020-02-21 11:36:41 +0100
commite95121bfd48318582526f79c52043c0df0e12d10 (patch)
tree35e7b5f23c31a767ac3aa419d71558eb3fcf1b5d
parent9c411dbbc58a4dee087644c9986f228504dda338 (diff)
downloadgrilo-e95121bfd48318582526f79c52043c0df0e12d10.tar.gz
net: Drop usage of deprecated GTimeVal
We can easily replace it with timestamp in seconds for the throttling feature.
-rw-r--r--libs/net/grl-net-wc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index b52c86c..9bd4922 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -79,8 +79,8 @@ struct _GrlNetWcPrivate {
SoupLoggerLogLevel log_level;
/* throttling in secs */
guint throttling;
- /* last request time */
- GTimeVal last_request;
+ /* last request time, timestamp in seconds */
+ gint64 last_request;
/* closure queue for delayed requests */
GQueue *pending;
/* cache size in Mb */
@@ -742,7 +742,7 @@ get_url (GrlNetWc *self,
GCancellable *cancellable)
{
guint id;
- GTimeVal now;
+ gint64 now;
struct request_clos *c;
GrlNetWcPrivate *priv = self->priv;
@@ -754,23 +754,23 @@ get_url (GrlNetWc *self,
c->result = result;
c->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
- g_get_current_time (&now);
+ now = g_get_real_time () / G_USEC_PER_SEC;
/* 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) {
+ || (now - priv->last_request) > priv->throttling) {
priv->last_request = now;
id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
get_url_cb, c, request_clos_destroy);
} else {
- priv->last_request.tv_sec += priv->throttling;
+ priv->last_request += priv->throttling;
GRL_DEBUG ("delaying web request by %lu seconds",
- priv->last_request.tv_sec - now.tv_sec);
+ priv->last_request - now);
id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
- priv->last_request.tv_sec - now.tv_sec,
+ priv->last_request - now,
get_url_cb, c, request_clos_destroy);
}
g_source_set_name_by_id (id, "[grl-net] get_url_cb");
@@ -1120,5 +1120,5 @@ grl_net_wc_flush_delayed_requests (GrlNetWc *self)
g_source_remove (c->source_id);
}
- g_get_current_time (&priv->last_request);
+ priv->last_request = g_get_real_time() / G_USEC_PER_SEC;
}