From ef7b66697f5b3261a451917d2996563a141df68a Mon Sep 17 00:00:00 2001 From: grunfink Date: Wed, 24 Jun 2026 14:54:45 +0200 Subject: 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. --- data.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'data.c') 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); -- cgit