Jelajahi Sumber

Kernel: Clear SO_ERROR on successful socket connection

When TCP sockets successfully establish a connection, any SO_ERROR
should be cleared back to success. For example, SO_ERROR gets set to
EINPROGRESS on asynchronous connect calls and should be cleared when
the socket moves to the Established state.
brapru 3 tahun lalu
induk
melakukan
6743170f4e
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      Kernel/Net/TCPSocket.cpp

+ 3 - 1
Kernel/Net/TCPSocket.cpp

@@ -38,8 +38,10 @@ void TCPSocket::set_state(State new_state)
 
     m_state = new_state;
 
-    if (new_state == State::Established && m_direction == Direction::Outgoing)
+    if (new_state == State::Established && m_direction == Direction::Outgoing) {
         m_role = Role::Connected;
+        [[maybe_unused]] auto rc = set_so_error(KSuccess);
+    }
 
     if (new_state == State::Closed) {
         closing_sockets().with_exclusive([&](auto& table) {