1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

Kernel: Remove unnecessary SocketHandle<T> class

This was used to return a pre-locked UDPSocket in one place, but there
was really no need for that mechanism in the first place since the
caller ends up locking the socket anyway.
This commit is contained in:
Andreas Kling 2021-12-25 11:23:57 +01:00
parent e923cf6624
commit 9965e59ad8
3 changed files with 4 additions and 45 deletions

View file

@ -183,44 +183,6 @@ private:
NonnullRefPtrVector<Socket> m_pending;
};
template<typename SocketType>
class SocketHandle {
public:
SocketHandle() = default;
SocketHandle(NonnullRefPtr<SocketType>&& socket)
: m_socket(move(socket))
{
if (m_socket)
m_socket->mutex().lock();
}
SocketHandle(SocketHandle&& other)
: m_socket(move(other.m_socket))
{
}
~SocketHandle()
{
if (m_socket)
m_socket->mutex().unlock();
}
SocketHandle(const SocketHandle&) = delete;
SocketHandle& operator=(const SocketHandle&) = delete;
operator bool() const { return m_socket; }
SocketType* operator->() { return &socket(); }
const SocketType* operator->() const { return &socket(); }
SocketType& socket() { return *m_socket; }
const SocketType& socket() const { return *m_socket; }
private:
RefPtr<SocketType> m_socket;
};
// This is a special variant of TRY() that also updates the socket's SO_ERROR field on error.
#define SOCKET_TRY(expression) \
({ \