mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
Kernel: Allow WorkQueue items allocation failures propagation
In most cases it's safe to abort the requested operation and go forward, however, in some places it's not clear yet how to handle these failures, therefore, we use the MUST() wrapper to force a kernel panic for now.
This commit is contained in:
parent
02566d8091
commit
1462211ccf
9 changed files with 75 additions and 19 deletions
|
@ -129,7 +129,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu
|
|||
// This is important so that we can safely write the buffer back,
|
||||
// which could cause page faults. Note that this may be called immediately
|
||||
// before Processor::deferred_call_queue returns!
|
||||
g_io_work->queue([this, result]() {
|
||||
auto work_item_creation_result = g_io_work->try_queue([this, result]() {
|
||||
dbgln_if(PATA_DEBUG, "IDEChannel::complete_current_request result: {}", (int)result);
|
||||
MutexLocker locker(m_lock);
|
||||
VERIFY(m_current_request);
|
||||
|
@ -137,6 +137,11 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu
|
|||
m_current_request.clear();
|
||||
current_request->complete(result);
|
||||
});
|
||||
if (work_item_creation_result.is_error()) {
|
||||
auto current_request = m_current_request;
|
||||
m_current_request.clear();
|
||||
current_request->complete(AsyncDeviceRequest::OutOfMemory);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_ide_status(u8 status)
|
||||
|
@ -218,7 +223,7 @@ bool IDEChannel::handle_irq(RegisterState const&)
|
|||
// Now schedule reading/writing the buffer as soon as we leave the irq handler.
|
||||
// This is important so that we can safely access the buffers, which could
|
||||
// trigger page faults
|
||||
g_io_work->queue([this]() {
|
||||
auto work_item_creation_result = g_io_work->try_queue([this]() {
|
||||
MutexLocker locker(m_lock);
|
||||
SpinlockLocker lock(m_request_lock);
|
||||
if (m_current_request->request_type() == AsyncBlockDeviceRequest::Read) {
|
||||
|
@ -249,6 +254,11 @@ bool IDEChannel::handle_irq(RegisterState const&)
|
|||
}
|
||||
}
|
||||
});
|
||||
if (work_item_creation_result.is_error()) {
|
||||
auto current_request = m_current_request;
|
||||
m_current_request.clear();
|
||||
current_request->complete(AsyncDeviceRequest::OutOfMemory);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue