From 29bf409442a808471d596e419abe231633b1de0a Mon Sep 17 00:00:00 2001 From: Akira Hayakawa Date: Fri, 1 Nov 2024 20:08:14 +0900 Subject: [PATCH] Move locking response cache --- sorock/src/process/command_log/consumer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sorock/src/process/command_log/consumer.rs b/sorock/src/process/command_log/consumer.rs index 4ed8600c..6adcde87 100644 --- a/sorock/src/process/command_log/consumer.rs +++ b/sorock/src/process/command_log/consumer.rs @@ -63,7 +63,6 @@ impl CommandLog { }; if do_process { - let mut response_cache = self.response_cache.lock(); debug!("process user@{process_index}"); match command { Command::Snapshot { .. } => { @@ -73,6 +72,7 @@ impl CommandLog { message, request_id, } => { + let mut response_cache = self.response_cache.lock(); if response_cache.should_execute(&request_id) { let resp = app.process_write(message, process_index).await?; response_cache.insert_response(request_id.clone(), resp); @@ -100,6 +100,7 @@ impl CommandLog { } } Command::CompleteRequest { request_id } => { + let mut response_cache = self.response_cache.lock(); response_cache.complete_response(&request_id); } _ => {}