mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
Kernel: connect() should fail with EISCONN for already-connected sockets.
Also make sure to reset the socket role if Socket::connect() fails.
This commit is contained in:
parent
4aa0ab4e08
commit
e48cbf3c8c
Notes:
sideshowbarker
2024-07-19 14:59:57 +09:00
Author: https://github.com/awesomekling
Commit: e48cbf3c8c
2 changed files with 6 additions and 1 deletions
|
@ -2502,11 +2502,15 @@ int Process::sys$connect(int sockfd, const sockaddr* address, socklen_t address_
|
|||
return -EBADF;
|
||||
if (!descriptor->is_socket())
|
||||
return -ENOTSOCK;
|
||||
if (descriptor->socket_role() == SocketRole::Connected)
|
||||
return -EISCONN;
|
||||
auto& socket = *descriptor->socket();
|
||||
descriptor->set_socket_role(SocketRole::Connecting);
|
||||
auto result = socket.connect(address, address_size);
|
||||
if (result.is_error())
|
||||
if (result.is_error()) {
|
||||
descriptor->set_socket_role(SocketRole::None);
|
||||
return result;
|
||||
}
|
||||
descriptor->set_socket_role(SocketRole::Connected);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue