Avoid Companion request tag collisions after login
This commit is contained in:
1 parent
01c5cc2836
commit
0a9a3e93c7
11 files changed
+106
-19
No files matched your search
@@ -5130,6 +5130,20 @@ bool MyMesh::allowRequestTag(uint32_t tag) {
|
||||
return !_request_tag_rejected;
|
||||
}
|
||||
|
||||
bool MyMesh::allocateRequestTag(uint32_t& tag) {
|
||||
// Login replies use the server's clock, so their retired tag can equal
|
||||
// the next locally generated request tag even with synchronized clocks.
|
||||
// Skip held tags instead of reporting BAD_STATE to the app. One history
|
||||
// slot belongs to this reservation, leaving at most HISTORY_SIZE - 1
|
||||
// collisions. Keep the wall clock and all stale-response guards intact.
|
||||
for (unsigned attempt = 0;
|
||||
attempt < mesh::CompanionDelayedReplies::HISTORY_SIZE; ++attempt) {
|
||||
tag = getRTCClock()->getCurrentTimeUnique();
|
||||
if (allowRequestTag(tag)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MyMesh::armPendingRequest(uint32_t tag, uint32_t timeout, bool flood) {
|
||||
const uint32_t now = _ms->getMillis();
|
||||
_delayed_replies.armRequest(tag, timeout, flood, now);
|
||||
|
||||
@@ -416,6 +416,7 @@ protected:
|
||||
uint32_t calcDirectTimeoutMillisFor(uint32_t pkt_airtime_millis, uint8_t path_len) const override;
|
||||
void onSendTimeout() override;
|
||||
bool allowRequestTag(uint32_t tag) override;
|
||||
bool allocateRequestTag(uint32_t& tag) override;
|
||||
|
||||
// DataStoreHost methods
|
||||
bool onContactLoaded(const ContactInfo& contact) override { return addContact(contact); }
|
||||
|
||||
Reference in new issue
Block a user