Skip to content

Commit

Permalink
Guard against sid != MULTIPLEXER_SID
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb committed Aug 14, 2023
1 parent 618cf14 commit a0b7a58
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,24 +501,26 @@ impl ConnectionHandler {
self.handle_flush().await?;
}
}
} else if let Some(multiplexer) = self.multiplexer.as_mut() {
let maybe_token = subject.strip_prefix(&multiplexer.prefix).to_owned();

if let Some(token) = maybe_token {
if let Some(sender) = multiplexer.senders.remove(token) {
let message = Message {
subject,
reply,
payload,
headers,
status,
description,
length,
};

sender.send(message).map_err(|_| {
io::Error::new(io::ErrorKind::Other, "request receiver closed")
})?;
} else if sid == MULTIPLEXER_SID {
if let Some(multiplexer) = self.multiplexer.as_mut() {
let maybe_token = subject.strip_prefix(&multiplexer.prefix).to_owned();

if let Some(token) = maybe_token {
if let Some(sender) = multiplexer.senders.remove(token) {
let message = Message {
subject,
reply,
payload,
headers,
status,
description,
length,
};

sender.send(message).map_err(|_| {
io::Error::new(io::ErrorKind::Other, "request receiver closed")
})?;
}
}
}
}
Expand Down

0 comments on commit a0b7a58

Please sign in to comment.