mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
RequestServer: Avoid race condition between timeout and socket creation
Part of this issue was fixed in 89877b3f40
but that only addressed the first layer of deferred_invoke, ignoring the
second one (which would cause a race if a request was sent to a host
immediately following a timeout event from the same host).
Fixes #23840.
This commit is contained in:
parent
973cc67e81
commit
5485e2a940
Notes:
sideshowbarker
2024-07-16 21:34:08 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/5485e2a940 Pull-request: https://github.com/SerenityOS/serenity/pull/23843 Issue: https://github.com/SerenityOS/serenity/issues/23840
@ -56,6 +56,9 @@ void request_did_finish(URL::URL const& url, Core::Socket const* socket)
|
||||
connection->job_data = {};
|
||||
connection->removal_timer->on_timeout = [ptr = connection.ptr(), &cache_entry, key = move(key), &cache]() mutable {
|
||||
Core::deferred_invoke([&, key = move(key), ptr] {
|
||||
if (ptr->has_started)
|
||||
return;
|
||||
|
||||
dbgln_if(REQUESTSERVER_DEBUG, "Removing no-longer-used connection {} (socket {})", ptr, ptr->socket);
|
||||
auto did_remove = cache_entry.remove_first_matching([&](auto& entry) { return entry == ptr; });
|
||||
VERIFY(did_remove);
|
||||
|
Loading…
Reference in New Issue
Block a user