From 7a7ae086f5d012a57c4155dfc916328f97163e99 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 27 Jul 2023 19:21:46 +0200 Subject: [PATCH] kernel: Use a did_close callback for UnixSockets --- kernel/src/net/UnixSocket.cpp | 6 ++++++ kernel/src/net/UnixSocket.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/kernel/src/net/UnixSocket.cpp b/kernel/src/net/UnixSocket.cpp index c5514bd8..e389d50e 100644 --- a/kernel/src/net/UnixSocket.cpp +++ b/kernel/src/net/UnixSocket.cpp @@ -11,12 +11,18 @@ UnixSocket::UnixSocket(UnixSocket* peer) : m_state(State::Connected), m_peer(pee } UnixSocket::~UnixSocket() +{ + did_close(); +} + +void UnixSocket::did_close() { if (m_peer) { m_peer->m_peer = nullptr; m_peer->m_state = State::Reset; } + m_state = State::Inactive; } void UnixSocket::connect_to_peer(UnixSocket* peer) diff --git a/kernel/src/net/UnixSocket.h b/kernel/src/net/UnixSocket.h index f03959c1..0f376cbf 100644 --- a/kernel/src/net/UnixSocket.h +++ b/kernel/src/net/UnixSocket.h @@ -21,6 +21,8 @@ class UnixSocket : public Socket Result bind(SharedPtr, struct sockaddr*, socklen_t) override; Result connect(struct sockaddr*, socklen_t) override; + void did_close() override; + void connect_to_peer(UnixSocket* peer); virtual ~UnixSocket();