mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:28:13 +00:00
Kernel: Rename "descriptor" to "description" where appropriate.
Now that FileDescription is called that, variables of that type should not be called "descriptor". This is kinda wordy but we'll get used to it.
This commit is contained in:
parent
1c5677032a
commit
c1bbd40b9e
17 changed files with 285 additions and 285 deletions
|
@ -89,7 +89,7 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
|
|||
return protocol_bind();
|
||||
}
|
||||
|
||||
KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
|
||||
KResult IPv4Socket::connect(FileDescription& description, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
|
||||
{
|
||||
ASSERT(!m_bound);
|
||||
if (address_size != sizeof(sockaddr_in))
|
||||
|
@ -101,7 +101,7 @@ KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address
|
|||
m_peer_address = IPv4Address((const byte*)&ia.sin_addr.s_addr);
|
||||
m_peer_port = ntohs(ia.sin_port);
|
||||
|
||||
return protocol_connect(descriptor, should_block);
|
||||
return protocol_connect(description, should_block);
|
||||
}
|
||||
|
||||
void IPv4Socket::attach(FileDescription&)
|
||||
|
@ -114,23 +114,23 @@ void IPv4Socket::detach(FileDescription&)
|
|||
--m_attached_fds;
|
||||
}
|
||||
|
||||
bool IPv4Socket::can_read(FileDescription& descriptor) const
|
||||
bool IPv4Socket::can_read(FileDescription& description) const
|
||||
{
|
||||
if (descriptor.socket_role() == SocketRole::Listener)
|
||||
if (description.socket_role() == SocketRole::Listener)
|
||||
return can_accept();
|
||||
if (protocol_is_disconnected())
|
||||
return true;
|
||||
return m_can_read;
|
||||
}
|
||||
|
||||
ssize_t IPv4Socket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
|
||||
ssize_t IPv4Socket::read(FileDescription& description, byte* buffer, ssize_t size)
|
||||
{
|
||||
return recvfrom(descriptor, buffer, size, 0, nullptr, 0);
|
||||
return recvfrom(description, buffer, size, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
ssize_t IPv4Socket::write(FileDescription& descriptor, const byte* data, ssize_t size)
|
||||
ssize_t IPv4Socket::write(FileDescription& description, const byte* data, ssize_t size)
|
||||
{
|
||||
return sendto(descriptor, data, size, 0, nullptr, 0);
|
||||
return sendto(description, data, size, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
bool IPv4Socket::can_write(FileDescription&) const
|
||||
|
@ -184,7 +184,7 @@ ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_lengt
|
|||
return protocol_send(data, data_length);
|
||||
}
|
||||
|
||||
ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
|
||||
ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
|
||||
{
|
||||
(void)flags;
|
||||
if (addr_length && *addr_length < sizeof(sockaddr_in))
|
||||
|
@ -212,7 +212,7 @@ ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t b
|
|||
}
|
||||
|
||||
load_receive_deadline();
|
||||
current->block(Thread::BlockedReceive, descriptor);
|
||||
current->block(Thread::BlockedReceive, description);
|
||||
|
||||
LOCKER(lock());
|
||||
if (!m_can_read) {
|
||||
|
|
|
@ -71,7 +71,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock)
|
||||
KResult LocalSocket::connect(FileDescription& description, const sockaddr* address, socklen_t address_size, ShouldBlock)
|
||||
{
|
||||
ASSERT(!m_bound);
|
||||
if (address_size != sizeof(sockaddr_un))
|
||||
|
@ -87,10 +87,10 @@ KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* addres
|
|||
kprintf("%s(%u) LocalSocket{%p} connect(%s)\n", current->process().name().characters(), current->pid(), this, safe_address);
|
||||
#endif
|
||||
|
||||
auto descriptor_or_error = VFS::the().open(safe_address, 0, 0, current->process().current_directory());
|
||||
if (descriptor_or_error.is_error())
|
||||
auto description_or_error = VFS::the().open(safe_address, 0, 0, current->process().current_directory());
|
||||
if (description_or_error.is_error())
|
||||
return KResult(-ECONNREFUSED);
|
||||
m_file = move(descriptor_or_error.value());
|
||||
m_file = move(description_or_error.value());
|
||||
|
||||
ASSERT(m_file->inode());
|
||||
if (!m_file->inode()->socket())
|
||||
|
@ -103,12 +103,12 @@ KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* addres
|
|||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
return current->wait_for_connect(descriptor);
|
||||
return current->wait_for_connect(description);
|
||||
}
|
||||
|
||||
void LocalSocket::attach(FileDescription& descriptor)
|
||||
void LocalSocket::attach(FileDescription& description)
|
||||
{
|
||||
switch (descriptor.socket_role()) {
|
||||
switch (description.socket_role()) {
|
||||
case SocketRole::Accepted:
|
||||
++m_accepted_fds_open;
|
||||
break;
|
||||
|
@ -123,9 +123,9 @@ void LocalSocket::attach(FileDescription& descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
void LocalSocket::detach(FileDescription& descriptor)
|
||||
void LocalSocket::detach(FileDescription& description)
|
||||
{
|
||||
switch (descriptor.socket_role()) {
|
||||
switch (description.socket_role()) {
|
||||
case SocketRole::Accepted:
|
||||
ASSERT(m_accepted_fds_open);
|
||||
--m_accepted_fds_open;
|
||||
|
@ -143,30 +143,30 @@ void LocalSocket::detach(FileDescription& descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
bool LocalSocket::can_read(FileDescription& descriptor) const
|
||||
bool LocalSocket::can_read(FileDescription& description) const
|
||||
{
|
||||
auto role = descriptor.socket_role();
|
||||
auto role = description.socket_role();
|
||||
if (role == SocketRole::Listener)
|
||||
return can_accept();
|
||||
if (role == SocketRole::Accepted)
|
||||
return !has_attached_peer(descriptor) || !m_for_server.is_empty();
|
||||
return !has_attached_peer(description) || !m_for_server.is_empty();
|
||||
if (role == SocketRole::Connected)
|
||||
return !has_attached_peer(descriptor) || !m_for_client.is_empty();
|
||||
return !has_attached_peer(description) || !m_for_client.is_empty();
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
|
||||
ssize_t LocalSocket::read(FileDescription& description, byte* buffer, ssize_t size)
|
||||
{
|
||||
auto role = descriptor.socket_role();
|
||||
auto role = description.socket_role();
|
||||
if (role == SocketRole::Accepted) {
|
||||
if (!descriptor.is_blocking()) {
|
||||
if (!description.is_blocking()) {
|
||||
if (m_for_server.is_empty())
|
||||
return -EAGAIN;
|
||||
}
|
||||
return m_for_server.read(buffer, size);
|
||||
}
|
||||
if (role == SocketRole::Connected) {
|
||||
if (!descriptor.is_blocking()) {
|
||||
if (!description.is_blocking()) {
|
||||
if (m_for_client.is_empty())
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
@ -175,41 +175,41 @@ ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t siz
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool LocalSocket::has_attached_peer(const FileDescription& descriptor) const
|
||||
bool LocalSocket::has_attached_peer(const FileDescription& description) const
|
||||
{
|
||||
if (descriptor.socket_role() == SocketRole::Accepted)
|
||||
if (description.socket_role() == SocketRole::Accepted)
|
||||
return m_connected_fds_open || m_connecting_fds_open;
|
||||
if (descriptor.socket_role() == SocketRole::Connected)
|
||||
if (description.socket_role() == SocketRole::Connected)
|
||||
return m_accepted_fds_open;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
ssize_t LocalSocket::write(FileDescription& descriptor, const byte* data, ssize_t size)
|
||||
ssize_t LocalSocket::write(FileDescription& description, const byte* data, ssize_t size)
|
||||
{
|
||||
if (!has_attached_peer(descriptor))
|
||||
if (!has_attached_peer(description))
|
||||
return -EPIPE;
|
||||
if (descriptor.socket_role() == SocketRole::Accepted)
|
||||
if (description.socket_role() == SocketRole::Accepted)
|
||||
return m_for_client.write(data, size);
|
||||
if (descriptor.socket_role() == SocketRole::Connected)
|
||||
if (description.socket_role() == SocketRole::Connected)
|
||||
return m_for_server.write(data, size);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool LocalSocket::can_write(FileDescription& descriptor) const
|
||||
bool LocalSocket::can_write(FileDescription& description) const
|
||||
{
|
||||
if (descriptor.socket_role() == SocketRole::Accepted)
|
||||
return !has_attached_peer(descriptor) || m_for_client.bytes_in_write_buffer() < 16384;
|
||||
if (descriptor.socket_role() == SocketRole::Connected)
|
||||
return !has_attached_peer(descriptor) || m_for_server.bytes_in_write_buffer() < 16384;
|
||||
if (description.socket_role() == SocketRole::Accepted)
|
||||
return !has_attached_peer(description) || m_for_client.bytes_in_write_buffer() < 16384;
|
||||
if (description.socket_role() == SocketRole::Connected)
|
||||
return !has_attached_peer(description) || m_for_server.bytes_in_write_buffer() < 16384;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
ssize_t LocalSocket::sendto(FileDescription& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
|
||||
ssize_t LocalSocket::sendto(FileDescription& description, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
|
||||
{
|
||||
return write(descriptor, (const byte*)data, data_size);
|
||||
return write(description, (const byte*)data, data_size);
|
||||
}
|
||||
|
||||
ssize_t LocalSocket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
|
||||
ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
|
||||
{
|
||||
return read(descriptor, (byte*)buffer, buffer_size);
|
||||
return read(description, (byte*)buffer, buffer_size);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ static const char* to_string(SocketRole role)
|
|||
}
|
||||
}
|
||||
|
||||
String Socket::absolute_path(const FileDescription& descriptor) const
|
||||
String Socket::absolute_path(const FileDescription& description) const
|
||||
{
|
||||
return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role()));
|
||||
return String::format("socket:%x (role: %s)", this, to_string(description.socket_role()));
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ NetworkOrdered<word> TCPSocket::compute_tcp_checksum(const IPv4Address& source,
|
|||
return ~(checksum & 0xffff);
|
||||
}
|
||||
|
||||
KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock should_block)
|
||||
KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock should_block)
|
||||
{
|
||||
auto* adapter = adapter_for_route_to(peer_address());
|
||||
if (!adapter)
|
||||
|
@ -162,7 +162,7 @@ KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock sho
|
|||
m_state = State::Connecting;
|
||||
|
||||
if (should_block == ShouldBlock::Yes) {
|
||||
current->block(Thread::BlockedConnect, descriptor);
|
||||
current->block(Thread::BlockedConnect, description);
|
||||
ASSERT(is_connected());
|
||||
return KSuccess;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue