Skip to content

Commit

Permalink
Make Reliability negotiation stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Sep 5, 2024
1 parent 34871cc commit 69a38eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 0 additions & 8 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,6 @@ pub enum Reliability {
impl Reliability {
pub const DEFAULT: Self = Self::BestEffort;

/// Returns `true` is `self` implies `other`.
pub fn implies(self, other: Self) -> bool {
!matches!(
(self, other),
(Reliability::Reliable, Reliability::BestEffort)
)
}

#[cfg(feature = "test")]
pub fn rand() -> Self {
use rand::Rng;
Expand Down
8 changes: 4 additions & 4 deletions io/zenoh-transport/src/unicast/establishment/ext/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ impl<'a> OpenFsm for &'a QoSFsm<'a> {
let reliability = match (self_reliability, other_reliability) {
(None, reliability) | (reliability, None) => reliability,
(Some(self_reliability), Some(other_reliability)) => {
if other_reliability.implies(self_reliability) {
if self_reliability == other_reliability {
Some(self_reliability)
} else {
return Err(zerror!(
"The Reliability received in InitAck cannot be substituted with my Reliability"
"The Reliability received in InitAck doesn't match my Reliability"
)
.into());
}
Expand Down Expand Up @@ -398,11 +398,11 @@ impl<'a> AcceptFsm for &'a QoSFsm<'a> {
let reliability = match (self_reliability, other_reliability) {
(None, reliability) | (reliability, None) => reliability,
(Some(self_reliability), Some(other_reliability)) => {
if self_reliability.implies(other_reliability) {
if self_reliability == other_reliability {
Some(other_reliability)
} else {
return Err(zerror!(
"The Reliability received in InitSyn cannot be substituted for my Reliability"
"The Reliability received in InitSyn doesn't match my Reliability"
)
.into());
}
Expand Down

0 comments on commit 69a38eb

Please sign in to comment.