diff --git a/modules/client/sync.cc b/modules/client/sync.cc index d6cddd73a..7f2298317 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -296,6 +296,9 @@ ircd::m::sync::handle_get(client &client, // in the range being considered by the sync. That threshold is // supplied by a conf item. && range.second - range.first <= size_t(linear_delta_max) + + // When the semaphore query param is set we don't need linear mode. + && !args.semaphore }; // Determine if polylog sync mode should be used. @@ -304,6 +307,9 @@ ircd::m::sync::handle_get(client &client, // Polylog mode is only used when neither of the other two modes // are determined. !should_longpoll && !should_linear + + // When the semaphore query param is set we don't need polylog mode. + && !args.semaphore }; // Determine if an empty sync response should be returned to the user. @@ -894,6 +900,11 @@ ircd::m::sync::longpoll::polled(data &data, if(!consumed) return false; + // In semaphore-mode we're just here to ride the longpoll's blocking + // behavior. We want the client to get an empty response. + if(args.semaphore) + return false; + const json::vector vector { string_view diff --git a/modules/client/sync/args.h b/modules/client/sync/args.h index d8cc8d0f3..f0283685e 100644 --- a/modules/client/sync/args.h +++ b/modules/client/sync/args.h @@ -105,5 +105,14 @@ struct ircd::m::sync::args request.query.get("phased", true) }; + /// (non-spec) If this is set to true, the only response content from /sync + /// will be a `next_batch` token. This is useful for clients that only want + /// to use /sync as a semaphore notifying about new activity, but will + /// retrieve the actual data another way. + bool semaphore + { + request.query.get("semaphore", false) + }; + args(const resource::request &request); };