diff --git a/src/asynchronous/client.rs b/src/asynchronous/client.rs index ed2ee3a8..2eb36e58 100644 --- a/src/asynchronous/client.rs +++ b/src/asynchronous/client.rs @@ -74,8 +74,9 @@ impl Client { let (tx, mut rx): (ResultSender, ResultReceiver) = mpsc::channel(100); - // TODO: check return. - self.streams.lock().unwrap().insert(stream_id, tx); + self.streams.lock().map(|mut x| { + x.insert(stream_id, tx); + }).map_err(|_| Error::Others("Failed to acquire lock on streams".to_string()))?; self.req_tx .send(msg) @@ -136,8 +137,10 @@ impl Client { } let (tx, rx): (ResultSender, ResultReceiver) = mpsc::channel(100); - // TODO: check return - self.streams.lock().unwrap().insert(stream_id, tx); + self.streams.lock().map(|mut x| { + x.insert(stream_id, tx); + }).map_err(|_| Error::Others("Failed to acquire lock on streams".to_string()))?; + self.req_tx .send(msg) .await