mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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.
This commit is contained in:
parent
2aaaee6744
commit
364f6a9bf0
Notes:
sideshowbarker
2024-07-17 10:10:18 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/364f6a9bf0 Pull-request: https://github.com/SerenityOS/serenity/pull/14578
10 changed files with 13 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue