fix(mesh/outbox): expire messages with zero TTL immediately
is_expired used age > ttl_secs, so a message with ttl_secs=0 whose age rounded to 0 seconds was considered live forever. Switch to >= so the zero-TTL boundary expires on the first check, matching the intuitive meaning of TTL and the behavior the tests assert.
This commit is contained in:
parent
9d42645aa3
commit
c5ea41d0cb
@ -52,7 +52,10 @@ impl PendingMessage {
|
|||||||
return true; // Can't parse = treat as expired
|
return true; // Can't parse = treat as expired
|
||||||
};
|
};
|
||||||
let age = chrono::Utc::now().signed_duration_since(created);
|
let age = chrono::Utc::now().signed_duration_since(created);
|
||||||
age.num_seconds() as u64 > self.ttl_secs
|
// Use `>=` so a ttl_secs=0 message is expired immediately (used by
|
||||||
|
// tests and by callers that want a fire-and-forget behavior when
|
||||||
|
// the relay can't deliver on first try).
|
||||||
|
age.num_seconds() as u64 >= self.ttl_secs
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if this message can be relayed further.
|
/// Check if this message can be relayed further.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user