1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

Kernel: Switch singletons to use new Singleton class

MemoryManager cannot use the Singleton class because
MemoryManager::initialize is called before the global constructors
are run. That caused the Singleton to be re-initialized, causing
it to create another MemoryManager instance.

Fixes #3226
This commit is contained in:
Tom 2020-08-24 19:35:19 -06:00 committed by Andreas Kling
parent ba6e4fb77f
commit d89582880e
46 changed files with 221 additions and 170 deletions

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Singleton.h>
#include <AK/Time.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/FileSystem/FileDescription.h>
@ -62,20 +63,18 @@ void TCPSocket::set_state(State new_state)
}
}
static AK::Singleton<Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>> s_socket_closing;
Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_sockets()
{
static Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>* s_map;
if (!s_map)
s_map = new Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>;
return *s_map;
return *s_socket_closing;
}
static AK::Singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>> s_socket_tuples;
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;
return *s_socket_tuples;
}
RefPtr<TCPSocket> TCPSocket::from_tuple(const IPv4SocketTuple& tuple)