dragonball: avoid obtaining lock twice in create_stdio_console

Fixes #7055

Signed-off-by: Fuu <fuu-open@linux.alibaba.com>
This commit is contained in:
Fuu 2023-06-07 16:08:22 +08:00
parent 5ad8aaf9df
commit 210a15794c

View File

@ -79,16 +79,17 @@ impl ConsoleManager {
.unwrap() .unwrap()
.set_output_stream(Some(Box::new(std::io::stdout()))); .set_output_stream(Some(Box::new(std::io::stdout())));
let stdin_handle = std::io::stdin(); let stdin_handle = std::io::stdin();
stdin_handle {
.lock() let guard = stdin_handle.lock();
.set_raw_mode() guard
.map_err(|e| DeviceMgrError::ConsoleManager(ConsoleManagerError::StdinHandle(e)))?; .set_raw_mode()
stdin_handle .map_err(ConsoleManagerError::StdinHandle)
.lock() .map_err(DeviceMgrError::ConsoleManager)?;
.set_non_block(true) guard
.map_err(ConsoleManagerError::StdinHandle) .set_non_block(true)
.map_err(DeviceMgrError::ConsoleManager)?; .map_err(ConsoleManagerError::StdinHandle)
.map_err(DeviceMgrError::ConsoleManager)?;
}
let handler = ConsoleEpollHandler::new(device, Some(stdin_handle), None, &self.logger); let handler = ConsoleEpollHandler::new(device, Some(stdin_handle), None, &self.logger);
self.subscriber_id = Some(self.epoll_mgr.add_subscriber(Box::new(handler))); self.subscriber_id = Some(self.epoll_mgr.add_subscriber(Box::new(handler)));
self.backend = Some(Backend::StdinHandle(std::io::stdin())); self.backend = Some(Backend::StdinHandle(std::io::stdin()));