summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorConrad Pankoff <deoxxa@fknsrs.biz>2019-09-08 19:35:41 +1000
committerAndreas Kling <awesomekling@gmail.com>2019-09-08 12:34:20 +0200
commitfeb6d1afe0c68488a3313183e61f4de98cb1546b (patch)
tree3424b46cc9bc47589eb05341e94fa75a0c04f028 /Kernel
parenta2b61e30c5ddd6b3bfca63e02ba5dd31ebd5b5f0 (diff)
downloadserenity-feb6d1afe0c68488a3313183e61f4de98cb1546b.zip
Kernel: Use a WeakPtr instead of a RefPtr for TCP socket originator
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Net/TCPSocket.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index 1a1c1cbced..bfbe5eda20 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -6,7 +6,8 @@
#include <AK/WeakPtr.h>
#include <Kernel/Net/IPv4Socket.h>
-class TCPSocket final : public IPv4Socket {
+class TCPSocket final : public IPv4Socket
+ , public Weakable<TCPSocket> {
public:
static void for_each(Function<void(TCPSocket&)>);
static NonnullRefPtr<TCPSocket> create(int protocol);
@@ -129,7 +130,8 @@ public:
static RefPtr<TCPSocket> from_endpoints(const IPv4Address& local_address, u16 local_port, const IPv4Address& peer_address, u16 peer_port);
RefPtr<TCPSocket> create_client(const IPv4Address& local_address, u16 local_port, const IPv4Address& peer_address, u16 peer_port);
- void set_originator(RefPtr<TCPSocket> originator) { m_originator = originator; }
+ void set_originator(TCPSocket& originator) { m_originator = originator.make_weak_ptr(); }
+ bool has_originator() { return !!m_originator; }
void release_to_originator();
void release_for_accept(RefPtr<TCPSocket>);
@@ -150,7 +152,7 @@ private:
virtual KResult protocol_bind() override;
virtual KResult protocol_listen() override;
- RefPtr<TCPSocket> m_originator;
+ WeakPtr<TCPSocket> m_originator;
HashMap<IPv4SocketTuple, NonnullRefPtr<TCPSocket>> m_pending_release_for_accept;
Direction m_direction { Direction::Unspecified };
Error m_error { Error::None };