Kernel: Cleanup TTY::read()
This commit is contained in:
		
							parent
							
								
									c1fd341698
								
							
						
					
					
						commit
						7c11ea3694
					
				|  | @ -251,7 +251,7 @@ namespace Kernel | |||
| 
 | ||||
| 	BAN::ErrorOr<size_t> TTY::read(size_t, void* buffer, size_t count) | ||||
| 	{ | ||||
| 		m_lock.lock(); | ||||
| 		LockGuard _(m_lock); | ||||
| 		while (!m_output.flush) | ||||
| 		{ | ||||
| 			m_lock.unlock(); | ||||
|  | @ -259,6 +259,12 @@ namespace Kernel | |||
| 			m_lock.lock(); | ||||
| 		} | ||||
| 
 | ||||
| 		if (m_output.bytes == 0) | ||||
| 		{ | ||||
| 			m_output.flush = false; | ||||
| 			return 0; | ||||
| 		} | ||||
| 
 | ||||
| 		size_t to_copy = BAN::Math::min<size_t>(count, m_output.bytes); | ||||
| 		memcpy(buffer, m_output.buffer.data(), to_copy); | ||||
| 
 | ||||
|  | @ -270,8 +276,6 @@ namespace Kernel | |||
| 
 | ||||
| 		m_output.semaphore.unblock(); | ||||
| 
 | ||||
| 		m_lock.unlock(); | ||||
| 
 | ||||
| 		return to_copy; | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue