summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-07-13 09:31:24 +0300
committerAndreas Kling <kling@serenityos.org>2022-07-21 16:39:22 +0200
commit364f6a9bf0e53fa9a6d2afd0b70b915e94203450 (patch)
tree888fdbec9072ce37287ac1cf4ee68a3480f2f5e9 /Kernel
parent2aaaee6744dfa9fb8dd64c00ac5efc520ebae368 (diff)
downloadserenity-364f6a9bf0e53fa9a6d2afd0b70b915e94203450.zip
Kernel: Remove the Socket::{protocol,}connect ShouldBlock argument
This argument is always set to description.is_blocking(), but description is also given as a separate argument, so there's no point to piping it through separately.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Net/IPv4Socket.cpp4
-rw-r--r--Kernel/Net/IPv4Socket.h4
-rw-r--r--Kernel/Net/LocalSocket.cpp2
-rw-r--r--Kernel/Net/LocalSocket.h2
-rw-r--r--Kernel/Net/Socket.h7
-rw-r--r--Kernel/Net/TCPSocket.cpp4
-rw-r--r--Kernel/Net/TCPSocket.h2
-rw-r--r--Kernel/Net/UDPSocket.cpp2
-rw-r--r--Kernel/Net/UDPSocket.h2
-rw-r--r--Kernel/Syscalls/socket.cpp2
10 files changed, 13 insertions, 18 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 497fdc49d1..2cbf7d523a 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -138,7 +138,7 @@ ErrorOr<void> IPv4Socket::listen(size_t backlog)
return protocol_listen(result.did_allocate);
}
-ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<sockaddr const*> address, socklen_t address_size, ShouldBlock should_block)
+ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<sockaddr const*> address, socklen_t address_size)
{
if (address_size != sizeof(sockaddr_in))
return set_so_error(EINVAL);
@@ -158,7 +158,7 @@ ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<so
m_peer_address = IPv4Address { 127, 0, 0, 1 };
m_peer_port = ntohs(safe_address.sin_port);
- return protocol_connect(description, should_block);
+ return protocol_connect(description);
}
bool IPv4Socket::can_read(OpenFileDescription const&, u64) const
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index 967419251a..1121df9a66 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -33,7 +33,7 @@ public:
virtual ErrorOr<void> close() override;
virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) override;
- virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
+ virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override;
virtual ErrorOr<void> listen(size_t) override;
virtual void get_local_address(sockaddr*, socklen_t*) override;
virtual void get_peer_address(sockaddr*, socklen_t*) override;
@@ -82,7 +82,7 @@ protected:
virtual ErrorOr<void> protocol_listen([[maybe_unused]] bool did_allocate_port) { return {}; }
virtual ErrorOr<size_t> protocol_receive(ReadonlyBytes /* raw_ipv4_packet */, UserOrKernelBuffer&, size_t, int) { return ENOTIMPL; }
virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) { return ENOTIMPL; }
- virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) { return {}; }
+ virtual ErrorOr<void> protocol_connect(OpenFileDescription&) { return {}; }
virtual ErrorOr<u16> protocol_allocate_local_port() { return ENOPROTOOPT; }
virtual ErrorOr<size_t> protocol_size(ReadonlyBytes /* raw_ipv4_packet */) { return ENOTIMPL; }
virtual bool protocol_is_disconnected() const { return false; }
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 71c1a1b7f8..bd98a77267 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -159,7 +159,7 @@ ErrorOr<void> LocalSocket::bind(Userspace<sockaddr const*> user_address, socklen
return {};
}
-ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<sockaddr const*> user_address, socklen_t address_size, ShouldBlock)
+ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<sockaddr const*> user_address, socklen_t address_size)
{
VERIFY(!m_bound);
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index 1eea1eb23b..ac94bfcd30 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -37,7 +37,7 @@ public:
// ^Socket
virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) override;
- virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
+ virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override;
virtual ErrorOr<void> listen(size_t) override;
virtual void get_local_address(sockaddr*, socklen_t*) override;
virtual void get_peer_address(sockaddr*, socklen_t*) override;
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index 6c0685b980..281d530e9b 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -18,11 +18,6 @@
namespace Kernel {
-enum class ShouldBlock {
- No = 0,
- Yes = 1
-};
-
class OpenFileDescription;
class Socket : public File {
@@ -79,7 +74,7 @@ public:
ErrorOr<void> shutdown(int how);
virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) = 0;
- virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock) = 0;
+ virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) = 0;
virtual ErrorOr<void> listen(size_t) = 0;
virtual void get_local_address(sockaddr*, socklen_t*) = 0;
virtual void get_peer_address(sockaddr*, socklen_t*) = 0;
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index cef70d588e..8ecbf3c111 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -420,7 +420,7 @@ ErrorOr<void> TCPSocket::protocol_listen(bool did_allocate_port)
return {};
}
-ErrorOr<void> TCPSocket::protocol_connect(OpenFileDescription& description, ShouldBlock should_block)
+ErrorOr<void> TCPSocket::protocol_connect(OpenFileDescription& description)
{
MutexLocker locker(mutex());
@@ -444,7 +444,7 @@ ErrorOr<void> TCPSocket::protocol_connect(OpenFileDescription& description, Shou
evaluate_block_conditions();
- if (should_block == ShouldBlock::Yes) {
+ if (description.is_blocking()) {
locker.unlock();
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted())
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index 8f7530214e..c2bfbdfb02 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -175,7 +175,7 @@ private:
virtual ErrorOr<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override;
virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) override;
- virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) override;
+ virtual ErrorOr<void> protocol_connect(OpenFileDescription&) override;
virtual ErrorOr<u16> protocol_allocate_local_port() override;
virtual ErrorOr<size_t> protocol_size(ReadonlyBytes raw_ipv4_packet) override;
virtual bool protocol_is_disconnected() const override;
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index ab198f77b4..88fc3388e2 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -105,7 +105,7 @@ ErrorOr<size_t> UDPSocket::protocol_send(UserOrKernelBuffer const& data, size_t
return data_length;
}
-ErrorOr<void> UDPSocket::protocol_connect(OpenFileDescription&, ShouldBlock)
+ErrorOr<void> UDPSocket::protocol_connect(OpenFileDescription&)
{
set_role(Role::Connected);
set_connected(true);
diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h
index d4980c9e37..d904f97e24 100644
--- a/Kernel/Net/UDPSocket.h
+++ b/Kernel/Net/UDPSocket.h
@@ -29,7 +29,7 @@ private:
virtual ErrorOr<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override;
virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) override;
virtual ErrorOr<size_t> protocol_size(ReadonlyBytes raw_ipv4_packet) override;
- virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) override;
+ virtual ErrorOr<void> protocol_connect(OpenFileDescription&) override;
virtual ErrorOr<u16> protocol_allocate_local_port() override;
virtual ErrorOr<void> protocol_bind() override;
};
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp
index c3a3c859eb..1689b04ea1 100644
--- a/Kernel/Syscalls/socket.cpp
+++ b/Kernel/Syscalls/socket.cpp
@@ -152,7 +152,7 @@ ErrorOr<FlatPtr> Process::sys$connect(int sockfd, Userspace<sockaddr const*> use
return ENOTSOCK;
auto& socket = *description->socket();
REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain());
- TRY(socket.connect(*description, user_address, user_address_size, description->is_blocking() ? ShouldBlock::Yes : ShouldBlock::No));
+ TRY(socket.connect(*description, user_address, user_address_size));
return 0;
}