Skip to content

Commit

Permalink
filtered port
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Dec 31, 2024
1 parent c8ce3f7 commit 101dd99
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mirrord/agent/src/steal/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,27 @@ impl<R: PortRedirector> PortSubscriptions<R> {
) -> Result<RemoteResult<Port>, R::Error> {
let add_redirect = match self.subscriptions.entry(port) {
Entry::Occupied(mut e) => {
let filtered = filter.is_some();
if e.get_mut().try_extend(client_id, filter) {
if filtered {
STEAL_FILTERED_PORT_SUBSCRIPTION.inc();
} else {
STEAL_UNFILTERED_PORT_SUBSCRIPTION.inc();
}

Ok(false)
} else {
Err(ResponseError::PortAlreadyStolen(port))
}
}

Entry::Vacant(e) => {
if filter.is_some() {
STEAL_FILTERED_PORT_SUBSCRIPTION.inc();
} else {
STEAL_UNFILTERED_PORT_SUBSCRIPTION.inc();
}

e.insert(PortSubscription::new(client_id, filter));
Ok(true)
}
Expand Down

0 comments on commit 101dd99

Please sign in to comment.