mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	Kernel: Make File's can_read/can_write take a const FileDescription&
Asking a File if we could possibly read or write it will never mutate the asking FileDescription&, so it should be const.
This commit is contained in:
		
							parent
							
								
									e8fee92357
								
							
						
					
					
						commit
						1b2ef8582c
					
				
					 47 changed files with 97 additions and 91 deletions
				
			
		|  | @ -144,7 +144,7 @@ void IPv4Socket::detach(FileDescription&) | |||
| { | ||||
| } | ||||
| 
 | ||||
| bool IPv4Socket::can_read(FileDescription&) const | ||||
| bool IPv4Socket::can_read(const FileDescription&) const | ||||
| { | ||||
|     if (m_role == Role::Listener) | ||||
|         return can_accept(); | ||||
|  | @ -153,7 +153,7 @@ bool IPv4Socket::can_read(FileDescription&) const | |||
|     return m_can_read; | ||||
| } | ||||
| 
 | ||||
| bool IPv4Socket::can_write(FileDescription&) const | ||||
| bool IPv4Socket::can_write(const FileDescription&) const | ||||
| { | ||||
|     return is_connected(); | ||||
| } | ||||
|  | @ -282,9 +282,13 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t | |||
|     return protocol_receive(packet.data.value(), buffer, buffer_length, flags); | ||||
| } | ||||
| 
 | ||||
| void IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, KBuffer&& packet) | ||||
| bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, KBuffer&& packet) | ||||
| { | ||||
|     LOCKER(lock()); | ||||
|     if (m_receive_queue.size_slow() > 2000) { | ||||
|         kprintf("IPv4Socket(%p): did_receive refusing packet since queue is full.\n", this); | ||||
|         return false; | ||||
|     } | ||||
|     auto packet_size = packet.size(); | ||||
|     m_receive_queue.append({ source_address, source_port, move(packet) }); | ||||
|     m_can_read = true; | ||||
|  | @ -292,6 +296,7 @@ void IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, | |||
| #ifdef IPV4_SOCKET_DEBUG | ||||
|     kprintf("IPv4Socket(%p): did_receive %d bytes, total_received=%u, packets in queue: %d\n", this, packet_size, m_bytes_received, m_receive_queue.size_slow()); | ||||
| #endif | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| String IPv4Socket::absolute_path(const FileDescription&) const | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling