[gupnp] ServiceProxy: Change subscription timeout point
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] ServiceProxy: Change subscription timeout point
- Date: Tue, 14 Jun 2022 06:14:11 +0000 (UTC)
commit b50c50dd6b27272b4e2207a6cf853defa0337684
Author: Jens Georg <mail jensge org>
Date: Mon Jun 13 12:57:51 2022 +0200
ServiceProxy: Change subscription timeout point
Previously we used a random timeout between 1 and timeout / 2. The code
now will jitter around the timeout/2 mark by +/- timeout/4 at max.
libgupnp/gupnp-service-proxy.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index 466885f..0287224 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -1216,8 +1216,19 @@ subscribe_got_response (GObject *source, GAsyncResult *res, gpointer user_data)
}
/* We want to resubscribe before the subscription
- * expires. */
- timeout = g_random_int_range (1, timeout / 2);
+ * expires. We do that somewhat around the middle of the
+ * subscription period and introduce some random jitter
+ * around that, so we do not bombard the services with
+ * all the re-subscription all at once
+ */
+ int jitter =
+ g_random_int_range (-timeout / 4, timeout / 4);
+ timeout = timeout / 2 + jitter;
+
+ g_debug ("Service announced timeout of %s, will "
+ "re-subscribe in %d seconds",
+ hdr,
+ timeout);
/* Add actual timeout */
priv->subscription_timeout_src =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]