mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Return EPIPE when trying to write to an unconnected socket
When attempting to write to a socket that is not connected or - for connection-less protocols - doesn't have a peer address set we should return EPIPE instead of blocking the thread.
This commit is contained in:
parent
51c2c69357
commit
0625342382
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/0625342382e Pull-request: https://github.com/SerenityOS/serenity/pull/7807
1 changed files with 4 additions and 1 deletions
|
@ -170,7 +170,7 @@ bool IPv4Socket::can_read(const FileDescription&, size_t) const
|
|||
|
||||
bool IPv4Socket::can_write(const FileDescription&, size_t) const
|
||||
{
|
||||
return is_connected();
|
||||
return true;
|
||||
}
|
||||
|
||||
PortAllocationResult IPv4Socket::allocate_local_port_if_needed()
|
||||
|
@ -206,6 +206,9 @@ KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer&
|
|||
m_peer_port = ntohs(ia.sin_port);
|
||||
}
|
||||
|
||||
if (!is_connected() && m_peer_address.is_zero())
|
||||
return EPIPE;
|
||||
|
||||
auto routing_decision = route_to(m_peer_address, m_local_address, bound_interface());
|
||||
if (routing_decision.is_zero())
|
||||
return EHOSTUNREACH;
|
||||
|
|
Loading…
Reference in a new issue