mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
AK+Kernel: Handle allocation failures in Device::try_make_request
This adds try_* methods to AK::DoublyLinkedList and updates the Device class to use those to gracefully handle allocation failures. Refs #6369.
This commit is contained in:
parent
b33834ca3a
commit
ab8b043684
2 changed files with 28 additions and 7 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
auto request = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) AsyncRequestType(*this, forward<Args>(args)...)));
|
||||
SpinlockLocker lock(m_requests_lock);
|
||||
bool was_empty = m_requests.is_empty();
|
||||
m_requests.append(request);
|
||||
TRY(m_requests.try_append(request));
|
||||
if (was_empty)
|
||||
request->do_start(move(lock));
|
||||
return request;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue