Add MemoryBlockRetrievalFailed() hook.
Adjust RetrieveMemoryBlockJob to call said hook if we fail to fulfill the memory read request.
This commit is contained in:
@@ -46,15 +46,19 @@ RetrieveMemoryBlockJob::Do()
|
|||||||
{
|
{
|
||||||
ssize_t result = fTeamMemory->ReadMemory(fMemoryBlock->BaseAddress(),
|
ssize_t result = fTeamMemory->ReadMemory(fMemoryBlock->BaseAddress(),
|
||||||
fMemoryBlock->Data(), fMemoryBlock->Size());
|
fMemoryBlock->Data(), fMemoryBlock->Size());
|
||||||
if (result < 0)
|
if (result < 0) {
|
||||||
|
fMemoryBlock->NotifyDataRetrieved(result);
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 protection = 0;
|
uint32 protection = 0;
|
||||||
uint32 locking = 0;
|
uint32 locking = 0;
|
||||||
status_t error = get_memory_properties(fTeam->ID(),
|
status_t error = get_memory_properties(fTeam->ID(),
|
||||||
(const void *)fMemoryBlock->BaseAddress(), &protection, &locking);
|
(const void *)fMemoryBlock->BaseAddress(), &protection, &locking);
|
||||||
if (error != B_OK)
|
if (error != B_OK) {
|
||||||
|
fMemoryBlock->NotifyDataRetrieved(error);
|
||||||
return error;
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
fMemoryBlock->SetWritable((protection & B_WRITE_AREA) != 0);
|
fMemoryBlock->SetWritable((protection & B_WRITE_AREA) != 0);
|
||||||
fMemoryBlock->MarkValid();
|
fMemoryBlock->MarkValid();
|
||||||
|
|||||||
@@ -93,11 +93,14 @@ TeamMemoryBlock::SetWritable(bool writable)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TeamMemoryBlock::NotifyDataRetrieved()
|
TeamMemoryBlock::NotifyDataRetrieved(status_t result)
|
||||||
{
|
{
|
||||||
for (ListenerList::Iterator it = fListeners.GetIterator();
|
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||||
Listener* listener = it.Next();) {
|
Listener* listener = it.Next();) {
|
||||||
listener->MemoryBlockRetrieved(this);
|
if (result == B_OK)
|
||||||
|
listener->MemoryBlockRetrieved(this);
|
||||||
|
else
|
||||||
|
listener->MemoryBlockRetrievalFailed(this, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,3 +126,10 @@ void
|
|||||||
TeamMemoryBlock::Listener::MemoryBlockRetrieved(TeamMemoryBlock* block)
|
TeamMemoryBlock::Listener::MemoryBlockRetrieved(TeamMemoryBlock* block)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamMemoryBlock::Listener::MemoryBlockRetrievalFailed(TeamMemoryBlock* block,
|
||||||
|
status_t result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
bool IsWritable() const { return fWritable; }
|
bool IsWritable() const { return fWritable; }
|
||||||
void SetWritable(bool writable);
|
void SetWritable(bool writable);
|
||||||
|
|
||||||
void NotifyDataRetrieved();
|
void NotifyDataRetrieved(status_t result = B_OK);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void LastReferenceReleased();
|
virtual void LastReferenceReleased();
|
||||||
@@ -69,6 +69,9 @@ public:
|
|||||||
virtual ~Listener();
|
virtual ~Listener();
|
||||||
|
|
||||||
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
||||||
|
|
||||||
|
virtual void MemoryBlockRetrievalFailed(TeamMemoryBlock* block,
|
||||||
|
status_t result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user