Skip to content

Commit

Permalink
chrone: add log warn and close channel old agent when have new connec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
marverlous811 committed Sep 28, 2024
1 parent 95625f7 commit cf6d2bb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/relayer/src/agent_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@ pub struct AgentStore {

impl AgentStore {
pub fn add(&self, id: u64, conn_id: u64, tx: Sender<Box<dyn ProxyTunnel>>) {
log::warn!("add new connection for agent {id}, old connection will deactive");
self.agents
if let Some(agent) = self
.agents
.write()
.expect("Should write agents")
.insert(id, AgentEntry { tx, conn_id });
.insert(id, AgentEntry { tx, conn_id })
{
log::warn!(
"add new connection for agent {id}, old connection {} will deactive",

Check warning on line 30 in crates/relayer/src/agent_store.rs

View workflow job for this annotation

GitHub Actions / typos

"deactive" should be "deactivate".
agent.conn_id
);
agent.tx.close();
}
}

pub fn get(&self, id: u64) -> Option<Sender<Box<dyn ProxyTunnel>>> {
Expand Down

0 comments on commit cf6d2bb

Please sign in to comment.