mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 21:40:33 +00:00
Kernel: Rename Socket::lock() => Socket::mutex()
"lock" is ambiguous (verb vs noun) while "mutex" is not.
This commit is contained in:
parent
0a7efb7d7b
commit
ed0e64943f
Notes:
sideshowbarker
2024-07-18 05:06:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ed0e64943f7
6 changed files with 24 additions and 24 deletions
|
@ -135,7 +135,7 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t addr
|
|||
|
||||
KResult IPv4Socket::listen(size_t backlog)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
auto result = allocate_local_port_if_needed();
|
||||
if (result.error_or_port.is_error() && result.error_or_port.error() != ENOPROTOOPT)
|
||||
return result.error_or_port.error();
|
||||
|
@ -190,7 +190,7 @@ bool IPv4Socket::can_write(const FileDescription&, size_t) const
|
|||
|
||||
PortAllocationResult IPv4Socket::allocate_local_port_if_needed()
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
if (m_local_port)
|
||||
return { m_local_port, false };
|
||||
auto port_or_error = protocol_allocate_local_port();
|
||||
|
@ -202,7 +202,7 @@ PortAllocationResult IPv4Socket::allocate_local_port_if_needed()
|
|||
|
||||
KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer& data, size_t data_length, [[maybe_unused]] int flags, Userspace<const sockaddr*> addr, socklen_t addr_length)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
|
||||
if (addr && addr_length != sizeof(sockaddr_in))
|
||||
return set_so_error(EINVAL);
|
||||
|
@ -261,7 +261,7 @@ KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer&
|
|||
|
||||
KResultOr<size_t> IPv4Socket::receive_byte_buffered(FileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
if (m_receive_buffer->is_empty()) {
|
||||
if (protocol_is_disconnected())
|
||||
return 0;
|
||||
|
@ -297,7 +297,7 @@ KResultOr<size_t> IPv4Socket::receive_byte_buffered(FileDescription& description
|
|||
|
||||
KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*> addr, Userspace<socklen_t*> addr_length, Time& packet_timestamp)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
ReceivedPacket packet;
|
||||
{
|
||||
if (m_receive_queue.is_empty()) {
|
||||
|
@ -412,7 +412,7 @@ KResultOr<size_t> IPv4Socket::recvfrom(FileDescription& description, UserOrKerne
|
|||
|
||||
bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, ReadonlyBytes packet, const Time& packet_timestamp)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
|
||||
if (is_shut_down_for_reading())
|
||||
return false;
|
||||
|
|
|
@ -238,7 +238,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
|
|||
|
||||
KResult LocalSocket::listen(size_t backlog)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
if (type() != SOCK_STREAM)
|
||||
return set_so_error(EOPNOTSUPP);
|
||||
set_backlog(backlog);
|
||||
|
@ -505,7 +505,7 @@ NonnullRefPtrVector<FileDescription>& LocalSocket::sendfd_queue_for(const FileDe
|
|||
|
||||
KResult LocalSocket::sendfd(const FileDescription& socket_description, FileDescription& passing_description)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
auto role = this->role(socket_description);
|
||||
if (role != Role::Connected && role != Role::Accepted)
|
||||
return set_so_error(EINVAL);
|
||||
|
@ -520,7 +520,7 @@ KResult LocalSocket::sendfd(const FileDescription& socket_description, FileDescr
|
|||
|
||||
KResultOr<NonnullRefPtr<FileDescription>> LocalSocket::recvfd(const FileDescription& socket_description)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
auto role = this->role(socket_description);
|
||||
if (role != Role::Connected && role != Role::Accepted)
|
||||
return set_so_error(EINVAL);
|
||||
|
|
|
@ -298,7 +298,7 @@ void handle_udp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
|
|||
|
||||
void send_delayed_tcp_ack(RefPtr<TCPSocket> socket)
|
||||
{
|
||||
VERIFY(socket->lock().is_locked());
|
||||
VERIFY(socket->mutex().is_locked());
|
||||
if (!socket->should_delay_next_ack()) {
|
||||
[[maybe_unused]] auto result = socket->send_ack();
|
||||
return;
|
||||
|
@ -311,7 +311,7 @@ void flush_delayed_tcp_acks()
|
|||
{
|
||||
Vector<RefPtr<TCPSocket>, 32> remaining_sockets;
|
||||
for (auto& socket : *delayed_ack_sockets) {
|
||||
MutexLocker locker(socket->lock());
|
||||
MutexLocker locker(socket->mutex());
|
||||
if (socket->should_delay_next_ack()) {
|
||||
remaining_sockets.append(socket);
|
||||
continue;
|
||||
|
@ -418,7 +418,7 @@ void handle_tcp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
|
|||
return;
|
||||
}
|
||||
|
||||
MutexLocker locker(socket->lock());
|
||||
MutexLocker locker(socket->mutex());
|
||||
|
||||
VERIFY(socket->type() == SOCK_STREAM);
|
||||
VERIFY(socket->local_port() == tcp_packet.destination_port());
|
||||
|
@ -448,7 +448,7 @@ void handle_tcp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
|
|||
dmesgln("handle_tcp: couldn't create client socket");
|
||||
return;
|
||||
}
|
||||
MutexLocker locker(client->lock());
|
||||
MutexLocker locker(client->mutex());
|
||||
dbgln_if(TCP_DEBUG, "handle_tcp: created new client socket with tuple {}", client->tuple().to_string());
|
||||
client->set_sequence_number(1000);
|
||||
client->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
|
||||
|
@ -648,7 +648,7 @@ void retransmit_tcp_packets()
|
|||
});
|
||||
|
||||
for (auto& socket : sockets) {
|
||||
MutexLocker socket_locker(socket.lock());
|
||||
MutexLocker socket_locker(socket.mutex());
|
||||
socket.retransmit_packets();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ void Socket::set_setup_state(SetupState new_setup_state)
|
|||
|
||||
RefPtr<Socket> Socket::accept()
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
MutexLocker locker(mutex());
|
||||
if (m_pending.is_empty())
|
||||
return nullptr;
|
||||
dbgln_if(SOCKET_DEBUG, "Socket({}) de-queueing connection", this);
|
||||
|
@ -72,7 +72,7 @@ RefPtr<Socket> Socket::accept()
|
|||
KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer)
|
||||
{
|
||||
dbgln_if(SOCKET_DEBUG, "Socket({}) queueing connection", this);
|
||||
MutexLocker locker(m_lock);
|
||||
MutexLocker locker(mutex());
|
||||
if (m_pending.size() >= m_backlog)
|
||||
return set_so_error(ECONNREFUSED);
|
||||
if (!m_pending.try_append(peer))
|
||||
|
@ -243,7 +243,7 @@ KResultOr<size_t> Socket::write(FileDescription& description, u64, const UserOrK
|
|||
|
||||
KResult Socket::shutdown(int how)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
if (type() == SOCK_STREAM && !is_connected())
|
||||
return set_so_error(ENOTCONN);
|
||||
if (m_role == Role::Listener)
|
||||
|
@ -266,7 +266,7 @@ KResult Socket::stat(::stat& st) const
|
|||
|
||||
void Socket::set_connected(bool connected)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
if (m_connected == connected)
|
||||
return;
|
||||
m_connected = connected;
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
GroupID acceptor_gid() const { return m_acceptor.gid; }
|
||||
const RefPtr<NetworkAdapter> bound_interface() const { return m_bound_interface; }
|
||||
|
||||
Mutex& lock() { return m_lock; }
|
||||
Mutex& mutex() { return m_mutex; }
|
||||
|
||||
// ^File
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override final;
|
||||
|
@ -149,7 +149,7 @@ protected:
|
|||
private:
|
||||
virtual bool is_socket() const final { return true; }
|
||||
|
||||
Mutex m_lock { "Socket" };
|
||||
Mutex m_mutex { "Socket"sv };
|
||||
|
||||
int m_domain { 0 };
|
||||
int m_type { 0 };
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
: m_socket(move(socket))
|
||||
{
|
||||
if (m_socket)
|
||||
m_socket->lock().lock();
|
||||
m_socket->mutex().lock();
|
||||
}
|
||||
|
||||
SocketHandle(SocketHandle&& other)
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
~SocketHandle()
|
||||
{
|
||||
if (m_socket)
|
||||
m_socket->lock().unlock();
|
||||
m_socket->mutex().unlock();
|
||||
}
|
||||
|
||||
SocketHandle(const SocketHandle&) = delete;
|
||||
|
|
|
@ -398,7 +398,7 @@ KResult TCPSocket::protocol_listen(bool did_allocate_port)
|
|||
|
||||
KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock should_block)
|
||||
{
|
||||
MutexLocker locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
|
||||
auto routing_decision = route_to(peer_address(), local_address());
|
||||
if (routing_decision.is_zero())
|
||||
|
@ -497,7 +497,7 @@ void TCPSocket::shut_down_for_writing()
|
|||
|
||||
KResult TCPSocket::close()
|
||||
{
|
||||
MutexLocker socket_locker(lock());
|
||||
MutexLocker locker(mutex());
|
||||
auto result = IPv4Socket::close();
|
||||
if (state() == State::CloseWait) {
|
||||
dbgln_if(TCP_SOCKET_DEBUG, " Sending FIN from CloseWait and moving into LastAck");
|
||||
|
|
Loading…
Reference in a new issue