1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Kernel: Fix race conditions processing async device requests

This commit is contained in:
Tom 2021-02-06 16:59:32 -07:00 committed by Andreas Kling
parent 8177f2474b
commit 5ccc3637e3
4 changed files with 23 additions and 41 deletions

View file

@ -91,15 +91,11 @@ void AsyncDeviceRequest::add_sub_request(NonnullRefPtr<AsyncDeviceRequest> sub_r
VERIFY(sub_request->m_parent_request == nullptr);
sub_request->m_parent_request = this;
bool should_start;
{
ScopedSpinLock lock(m_lock);
VERIFY(!is_completed_result(m_result));
m_sub_requests_pending.append(sub_request);
should_start = (m_result == Started);
}
if (should_start)
sub_request->do_start();
ScopedSpinLock lock(m_lock);
VERIFY(!is_completed_result(m_result));
m_sub_requests_pending.append(sub_request);
if (m_result == Started)
sub_request->do_start(move(lock));
}
void AsyncDeviceRequest::sub_request_finished(AsyncDeviceRequest& sub_request)