summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-22 17:53:34 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-22 18:01:59 +0200
commit2fd9e722647b0a9b90b0380b898c17787918b451 (patch)
tree812bea0de4c6d9ce8767ea3b7d0dc1a0a6eb331b /Kernel/Net
parent0addcb45b83cc46382dc249619b0ae1f12c59dba (diff)
downloadserenity-2fd9e722647b0a9b90b0380b898c17787918b451.zip
Revert "Kernel: Switch singletons to use new Singleton class"
This reverts commit f48feae0b2a300992479abf0b2ded85e45ac6045.
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/IPv4Socket.cpp6
-rw-r--r--Kernel/Net/LocalSocket.cpp6
-rw-r--r--Kernel/Net/LoopbackAdapter.cpp8
-rw-r--r--Kernel/Net/LoopbackAdapter.h4
-rw-r--r--Kernel/Net/NetworkAdapter.cpp8
-rw-r--r--Kernel/Net/Routing.cpp8
-rw-r--r--Kernel/Net/TCPSocket.cpp6
-rw-r--r--Kernel/Net/UDPSocket.cpp6
8 files changed, 27 insertions, 25 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 8286e5a2e8..6e4fcfcbfa 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -25,7 +25,6 @@
*/
#include <AK/StringBuilder.h>
-#include <Kernel/Singleton.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/ICMP.h>
@@ -46,10 +45,11 @@
namespace Kernel {
-static auto s_table = make_singleton<Lockable<HashTable<IPv4Socket*>>>();
-
Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
{
+ static Lockable<HashTable<IPv4Socket*>>* s_table;
+ if (!s_table)
+ s_table = new Lockable<HashTable<IPv4Socket*>>;
return *s_table;
}
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index c703cc8ac6..92f333ad23 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -29,7 +29,6 @@
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Process.h>
-#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
@@ -38,10 +37,11 @@
namespace Kernel {
-static auto s_list = make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
-
Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
{
+ static Lockable<InlineLinkedList<LocalSocket>>* s_list;
+ if (!s_list)
+ s_list = new Lockable<InlineLinkedList<LocalSocket>>();
return *s_list;
}
diff --git a/Kernel/Net/LoopbackAdapter.cpp b/Kernel/Net/LoopbackAdapter.cpp
index 27faa8bfad..e42ee66a5e 100644
--- a/Kernel/Net/LoopbackAdapter.cpp
+++ b/Kernel/Net/LoopbackAdapter.cpp
@@ -25,15 +25,15 @@
*/
#include <Kernel/Net/LoopbackAdapter.h>
-#include <Kernel/Singleton.h>
namespace Kernel {
-static auto s_loopback = make_singleton<LoopbackAdapter>();
-
LoopbackAdapter& LoopbackAdapter::the()
{
- return *s_loopback;
+ static LoopbackAdapter* the;
+ if (!the)
+ the = new LoopbackAdapter;
+ return *the;
}
LoopbackAdapter::LoopbackAdapter()
diff --git a/Kernel/Net/LoopbackAdapter.h b/Kernel/Net/LoopbackAdapter.h
index cebedfe7a3..b87bb5003f 100644
--- a/Kernel/Net/LoopbackAdapter.h
+++ b/Kernel/Net/LoopbackAdapter.h
@@ -33,13 +33,15 @@ namespace Kernel {
class LoopbackAdapter final : public NetworkAdapter {
AK_MAKE_ETERNAL
public:
- LoopbackAdapter();
static LoopbackAdapter& the();
virtual ~LoopbackAdapter() override;
virtual void send_raw(ReadonlyBytes) override;
virtual const char* class_name() const override { return "LoopbackAdapter"; }
+
+private:
+ LoopbackAdapter();
};
}
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index 936bf9a2e7..7efa7b353e 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -33,16 +33,16 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
namespace Kernel {
-static auto s_table = make_singleton<Lockable<HashTable<NetworkAdapter*>>>();
-
static Lockable<HashTable<NetworkAdapter*>>& all_adapters()
{
- return *s_table;
+ static Lockable<HashTable<NetworkAdapter*>>* table;
+ if (!table)
+ table = new Lockable<HashTable<NetworkAdapter*>>;
+ return *table;
}
void NetworkAdapter::for_each(Function<void(NetworkAdapter&)> callback)
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 5f72ab1166..b2b9786a2e 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -28,17 +28,17 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/Routing.h>
#include <Kernel/Thread.h>
-#include <Kernel/Singleton.h>
//#define ROUTING_DEBUG
namespace Kernel {
-static auto s_arp_table = make_singleton<Lockable<HashMap<IPv4Address, MACAddress>>>();
-
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
{
- return *s_arp_table;
+ static Lockable<HashMap<IPv4Address, MACAddress>>* the;
+ if (!the)
+ the = new Lockable<HashMap<IPv4Address, MACAddress>>;
+ return *the;
}
bool RoutingDecision::is_zero() const
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 7b8c12a49c..cafe48370e 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -33,7 +33,6 @@
#include <Kernel/Net/TCPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
//#define TCP_SOCKET_DEBUG
@@ -71,10 +70,11 @@ Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_socket
return *s_map;
}
-static auto s_map = make_singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>>();
-
Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
{
+ static Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>* s_map;
+ if (!s_map)
+ s_map = new Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>;
return *s_map;
}
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index ad57696675..65091a37c1 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -31,7 +31,6 @@
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
namespace Kernel {
@@ -42,10 +41,11 @@ void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
callback(*it.value);
}
-static auto s_map = make_singleton<Lockable<HashMap<u16, UDPSocket*>>>();
-
Lockable<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
{
+ static Lockable<HashMap<u16, UDPSocket*>>* s_map;
+ if (!s_map)
+ s_map = new Lockable<HashMap<u16, UDPSocket*>>;
return *s_map;
}