aboutsummaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2026-06-24 14:54:45 +0200
committergrunfink <grunfink@comam.es>2026-06-24 14:54:45 +0200
commitef7b66697f5b3261a451917d2996563a141df68a (patch)
tree71c0f409f07dbd25ebde0c17543e93ad934781cc /data.c
parent778046fa7ab73e64b6a30021f1c81fc72c58bea7 (diff)
Implemented semi-random forward_secs in enqueue_object_request() or enqueue_actor_refresh().
If forward_secs is a negative value in these functions, it's used as the modulo of a hash of the user id. This way, a refresh storm of the same object by all users is somewhat distributed in time.
Diffstat (limited to 'data.c')
-rw-r--r--data.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/data.c b/data.c
index 3f7ba29..9500474 100644
--- a/data.c
+++ b/data.c
@@ -3858,6 +3858,11 @@ void enqueue_close_question(snac *user, const char *id, int end_secs)
void enqueue_object_request(snac *user, const char *id, int forward_secs)
/* enqueues the request of an object in the future */
{
+ if (forward_secs < 0) {
+ /* set it to a somewhat random delay */
+ forward_secs = xs_hash_func(user->uid, strlen(user->uid)) % -forward_secs;
+ }
+
xs *qmsg = _new_qmsg("object_request", id, 0);
xs *ntid = tid(forward_secs);
xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);
@@ -3886,6 +3891,11 @@ void enqueue_verify_links(snac *user)
void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs)
/* enqueues an actor refresh */
{
+ if (forward_secs < 0) {
+ /* set it to a somewhat random delay */
+ forward_secs = xs_hash_func(user->uid, strlen(user->uid)) % -forward_secs;
+ }
+
xs *qmsg = _new_qmsg("actor_refresh", "", 0);
xs *ntid = tid(forward_secs);
xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);