mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:52:44 +00:00 
			
		
		
		
	Kernel: Report EAGAIN from read() on a non-blocking socket if the buffer is empty
This is not EOF, and never should have been so -- can trip up other code when porting. Also updates LibGUI and WindowServer which both relied on the old behaviour (and didn't work without changes). There may be others, but I didn't run into them with a quick inspection.
This commit is contained in:
		
							parent
							
								
									40a5eb4e6e
								
							
						
					
					
						commit
						a8864dc590
					
				
					 3 changed files with 20 additions and 11 deletions
				
			
		|  | @ -153,10 +153,20 @@ bool LocalSocket::can_read(FileDescriptor& descriptor) const | |||
| ssize_t LocalSocket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size) | ||||
| { | ||||
|     auto role = descriptor.socket_role(); | ||||
|     if (role == SocketRole::Accepted) | ||||
|     if (role == SocketRole::Accepted) { | ||||
|         if (!descriptor.is_blocking()) { | ||||
|             if (m_for_server.is_empty()) | ||||
|                 return -EAGAIN; | ||||
|         } | ||||
|         return m_for_server.read(buffer, size); | ||||
|     if (role == SocketRole::Connected) | ||||
|     } | ||||
|     if (role == SocketRole::Connected) { | ||||
|         if (!descriptor.is_blocking()) { | ||||
|             if (m_for_client.is_empty()) | ||||
|                 return -EAGAIN; | ||||
|         } | ||||
|         return m_for_client.read(buffer, size); | ||||
|     } | ||||
|     ASSERT_NOT_REACHED(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robin Burchell
						Robin Burchell