From c3d702431ac606310fe129154db039fcab60f25f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 11 Jun 2021 08:43:17 +0200 Subject: [PATCH] Kernel: Block writes while we're establishing the TCP connection Previously we would not block the caller until the connection was established and would instead return EPIPE for the first send() call which then likely caused the caller to abandon the socket. This was broken by 0625342. --- Kernel/Net/TCPSocket.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 0fdb838355..cbf1af0f9f 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -584,6 +584,9 @@ bool TCPSocket::can_write(const FileDescription& file_description, size_t size) if (!IPv4Socket::can_write(file_description, size)) return false; + if (m_state == State::SynSent || m_state == State::SynReceived) + return false; + if (!file_description.is_blocking()) return true;