From 815ef693a145bb8a13591e9afe2ad2c507cfadd8 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 25 May 2023 14:30:25 +0530 Subject: [PATCH] fix: rm deadlock --- src/store/mod.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/store/mod.rs b/src/store/mod.rs index ef2b298..49a6022 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -394,20 +394,19 @@ impl RaftStorage for Arc { EntryPayload::Blank => res.push(ExampleResponse::Empty), EntryPayload::Normal(ref req) => match req { ExampleRequest::AddVisitor(msg) => { - let sm = self.state_machine.read().await; - res.push(ExampleResponse::AddVisitorResult( - sm.data - .master - .send(msg.clone()) - .await - .unwrap() - .await - .unwrap() - .unwrap(), - )); + let r = sm + .data + .master + .send(msg.clone()) + .await + .unwrap() + .await + .unwrap() + .unwrap(); + + res.push(ExampleResponse::AddVisitorResult(r)); } ExampleRequest::AddCaptcha(msg) => { - let sm = self.state_machine.read().await; sm.data .master .send(msg.clone()) @@ -419,7 +418,6 @@ impl RaftStorage for Arc { res.push(ExampleResponse::Empty); } ExampleRequest::RenameCaptcha(msg) => { - let sm = self.state_machine.read().await; sm.data .master .send(msg.clone()) @@ -431,7 +429,6 @@ impl RaftStorage for Arc { res.push(ExampleResponse::Empty); } ExampleRequest::RemoveCaptcha(msg) => { - let sm = self.state_machine.read().await; sm.data .master .send(msg.clone())