From 03f923c772d4ed2278b8f2a75998f4107407f8b9 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 15 Mar 2020 12:47:31 +0100 Subject: [PATCH] Fix deadlock when waiting for decompression result --- Cargo.toml | 2 +- src/io.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 30f0ee8..bb5afc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdflib" -version = "0.4.0" +version = "0.4.1" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/io.rs b/src/io.rs index 68fc620..eb428f9 100644 --- a/src/io.rs +++ b/src/io.rs @@ -66,6 +66,14 @@ impl ThreadManager { drop(sender); } + /// Drops the receiver + pub fn drop_sender_result(&mut self) { + let sender = self.sender_result.clone(); + let (s2,_) = bounded(0); + self.sender_result = s2; + drop(sender); + } + /// Waits for the wait group pub fn wait(&mut self) { let wg = self.wg.clone(); @@ -257,6 +265,7 @@ impl BDFReader { break; } } + self.thread_manager.drop_sender_result(); } /// Adds a chunk to the decompression channel to be decompressed by a worker thread