Kernel/LibC: Implement SOCK_CLOEXEC and SOCK_NONBLOCK
This removes the need for fcntl after creating a socket :)
This commit is contained in:
@@ -67,7 +67,7 @@ namespace Kernel
|
||||
dprintln_if(DEBUG_TCP, "Socket destroyed");
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> TCPSocket::accept_impl(sockaddr* address, socklen_t* address_len)
|
||||
BAN::ErrorOr<long> TCPSocket::accept_impl(sockaddr* address, socklen_t* address_len, int flags)
|
||||
{
|
||||
if (m_state != State::Listen)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
@@ -123,7 +123,7 @@ namespace Kernel
|
||||
memcpy(address, &connection.target.address, *address_len);
|
||||
}
|
||||
|
||||
return TRY(Process::current().open_inode(return_inode, O_RDWR));
|
||||
return TRY(Process::current().open_inode(return_inode, O_RDWR | flags));
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> TCPSocket::connect_impl(const sockaddr* address, socklen_t address_len)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> UnixDomainSocket::accept_impl(sockaddr* address, socklen_t* address_len)
|
||||
BAN::ErrorOr<long> UnixDomainSocket::accept_impl(sockaddr* address, socklen_t* address_len, int flags)
|
||||
{
|
||||
if (!m_info.has<ConnectionInfo>())
|
||||
return BAN::Error::from_errno(EOPNOTSUPP);
|
||||
@@ -104,7 +104,7 @@ namespace Kernel
|
||||
strncpy(sockaddr_un.sun_path, pending->m_bound_path.data(), copy_len);
|
||||
}
|
||||
|
||||
return TRY(Process::current().open_inode(return_inode, O_RDWR));
|
||||
return TRY(Process::current().open_inode(return_inode, O_RDWR | flags));
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> UnixDomainSocket::connect_impl(const sockaddr* address, socklen_t address_len)
|
||||
|
||||
Reference in New Issue
Block a user