Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/dht_proxy_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,28 @@ DhtProxyClient::pushNotificationReceived([[maybe_unused]] const std::map<std::st
try {
auto sessionId = notification.find("s");
if (sessionId != notification.end() and sessionId->second != pushSessionId_) {
// The push was requested by another client instance sharing this
// push token and client id (e.g. the iOS notification extension
// subscribing while the app was suspended): the proxy now tags
// pushes with that other session. The notification still means
// that values are available for the given key, so if we listen
Comment on lines +1263 to +1267
// on it, resubscribe (with refresh) to retrieve pending values
// immediately and re-associate the proxy-side subscription with
// this session, instead of dropping the notification.
auto keyIt = notification.find("key");
if (keyIt != notification.end()) {
std::lock_guard lock(searchLock_);
auto search = searches_.find(InfoHash(keyIt->second));
if (search != searches_.end() and not search->second.listeners.empty()) {
if (logger_)
logger_->debug("[proxy:client] [push] wrong session for [search {}], resubscribing",
search->first);
for (auto& list : search->second.listeners)
resubscribe(search->first, list.first, list.second);
loopSignal_();
return PushNotificationResult::ListenRefresh;
}
Comment on lines +1273 to +1283
}
if (logger_)
logger_->debug("[proxy:client] [push] ignoring push for other session");
return PushNotificationResult::IgnoredWrongSession;
Expand Down
Loading