Merge pull request #7056 from FuuuOverclocking/fuu/fix-console_manager

dragonball: avoid obtaining lock twice in create_stdio_console
This commit is contained in:
GabyCT 2023-06-23 16:47:00 -06:00 committed by GitHub
commit 388b55175e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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