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

WebServer: Defer invocation of Client::remove_from_parent()

This is necessary to avoid trying to destruct the on_ready_to_read
function from inside the function. This fixes #7810.
This commit is contained in:
Max Wipfli 2021-06-05 15:50:57 +02:00 committed by Andreas Kling
parent 5408111aff
commit 6e6ff844d3

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -33,7 +34,10 @@ Client::Client(NonnullRefPtr<Core::TCPSocket> socket, String const& root, Core::
void Client::die()
{
remove_from_parent();
deferred_invoke([this](auto& object) {
NonnullRefPtr protector { object };
remove_from_parent();
});
}
void Client::start()