diff --git a/modules/client/sync.cc b/modules/client/sync.cc index ee6c76b81..d53159021 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -86,8 +86,7 @@ ircd::m::sync::handle_get(client &client, // exist yet because it is one past the server's current_sequence counter. const m::events::range range { - args.since, // start at since token - m::vm::current_sequence + 1 // stop before future + args.since, std::min(args.next_batch, m::vm::current_sequence + 1) }; // When the range indexes are the same, the client is polling for the next diff --git a/modules/client/sync.h b/modules/client/sync.h index 7db3fac99..3d1b25c30 100644 --- a/modules/client/sync.h +++ b/modules/client/sync.h @@ -101,6 +101,18 @@ struct ircd::m::sync::args request.query.get("since", 0) }; + uint64_t next_batch + { + // [experimental] A upper bound to stop this sync at. This is used in + // conjunction with `since` to provide a stable window of results. If + // not specified the sync range is everything after `since`. NOTE that + // this DOES NOT guarantee true idempotency in all cases and for all + // time. But that would be nice. Many sync modules do not support this + // because the results of repeated calls for range may become empty + // after a while. + request.query.get("next_batch", -1) + }; + steady_point timesout{[this] { // 6.2.1 The maximum time to poll in milliseconds before returning this request.