Avoid overwriting io thread results.

Just block until it's done so that things are synchronous.
This commit is contained in:
Unknown W. Brackets committed 2014-03-02 13:45:12 -08:00
1 parent 0f36b45f2e
commit 2c40cd509a
3 files changed
+32 -2

No files matched your search

+21 -2
View File
@@ -742,7 +742,17 @@ bool __IoRead(int &result, int id, u32 data_addr, int size) {
if (f->npdrm) {
result = npdrmRead(f, data, size);
return true;
} else if (__KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE) {
}
bool useThread = __KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE;
if (useThread) {
// If there's a pending operation on this file, wait for it to finish and don't overwrite it.
useThread = !ioManager.HasOperation(f->handle);
if (!useThread) {
ioManager.SyncThread();
}
}
if (useThread) {
AsyncIOEvent ev = IO_EVENT_READ;
ev.handle = f->handle;
ev.buf = data;
@@ -854,7 +864,16 @@ bool __IoWrite(int &result, int id, u32 data_addr, int size) {
result = ERROR_KERNEL_BAD_FILE_DESCRIPTOR;
return true;
}
if (__KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE) {
bool useThread = __KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE;
if (useThread) {
// If there's a pending operation on this file, wait for it to finish and don't overwrite it.
useThread = !ioManager.HasOperation(f->handle);
if (!useThread) {
ioManager.SyncThread();
}
}
if (useThread) {
AsyncIOEvent ev = IO_EVENT_WRITE;
ev.handle = f->handle;
ev.buf = (u8 *) data_ptr;
+10
View File
@@ -21,6 +21,16 @@
#include "Core/HW/AsyncIOManager.h"
#include "Core/FileSystems/MetaFileSystem.h"
bool AsyncIOManager::HasOperation(u32 handle) {
if (resultsPending_.find(handle) != resultsPending_.end()) {
return true;
}
if (results_.find(handle) != results_.end()) {
return true;
}
return false;
}
void AsyncIOManager::ScheduleOperation(AsyncIOEvent ev) {
lock_guard guard(resultsLock_);
if (!resultsPending_.insert(ev.handle).second) {
+1
View File
@@ -51,6 +51,7 @@ class AsyncIOManager : public IOThreadEventQueue {
public:
void DoState(PointerWrap &p);
bool HasOperation(u32 handle);
void ScheduleOperation(AsyncIOEvent ev);
void Shutdown();