diff options
author | Jens Georg <mail@jensge.org> | 2022-06-13 12:57:51 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-06-14 08:12:32 +0200 |
commit | b50c50dd6b27272b4e2207a6cf853defa0337684 (patch) | |
tree | afa1358a85a257af9abad04c120cc3798cfb8131 | |
parent | 841d42b3e19cb48ca40d80ea212901188bd13dfb (diff) | |
download | gupnp-b50c50dd6b27272b4e2207a6cf853defa0337684.tar.gz |
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.
-rw-r--r-- | libgupnp/gupnp-service-proxy.c | 15 |
1 files 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 = |