From 9da5931435024572c1a586b4d353a5c0511f743d Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 7 Nov 2020 23:03:30 +0100 Subject: [PATCH] Fix memory leak for real Signed-off-by: trivernis --- Cargo.toml | 2 +- src/server/mod.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 373aa86..92a6615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "vented" description = "Event driven encrypted tcp communicaton" -version = "0.4.1" +version = "0.4.2" authors = ["trivernis "] edition = "2018" readme = "README.md" diff --git a/src/server/mod.rs b/src/server/mod.rs index 8c72148..2497144 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -305,7 +305,13 @@ impl VentedServer { self.redirect_handles .lock() .insert(payload.id, Future::clone(&future)); - self.emit(node.id, Event::with_payload(REDIRECT_EVENT, &payload))?; + + if let Ok(stream) = self.get_connection(&node.id) { + if let Err(e) = stream.send(Event::with_payload(REDIRECT_EVENT, &payload)) { + log::error!("Failed to send event: {}", e); + self.connections.lock().remove(stream.receiver_node()); + } + } if let Some(value) = future.get_value_with_timeout(1000) { if value {