mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: memfs: slowio: improvements
This commit is contained in:
parent
d3f829b2df
commit
9f2fe92db7
@ -21,9 +21,11 @@
|
|||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <thread>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
/* SLOWIO */
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#define MEMFS_MAX_PATH 512
|
#define MEMFS_MAX_PATH 512
|
||||||
FSP_FSCTL_STATIC_ASSERT(MEMFS_MAX_PATH > MAX_PATH,
|
FSP_FSCTL_STATIC_ASSERT(MEMFS_MAX_PATH > MAX_PATH,
|
||||||
"MEMFS_MAX_PATH must be greater than MAX_PATH.");
|
"MEMFS_MAX_PATH must be greater than MAX_PATH.");
|
||||||
@ -1165,22 +1167,20 @@ static NTSTATUS Read(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
if (SlowioReturnPending(FileSystem))
|
if (SlowioReturnPending(FileSystem))
|
||||||
{
|
{
|
||||||
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspFileSystemGetOperationContext()->Request;
|
try
|
||||||
UINT64 RequestHint = Request->Hint;
|
{
|
||||||
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
||||||
try {
|
std::thread(SlowioReadThread,
|
||||||
auto Thread = std::thread(SlowioReadThread,
|
FileSystem, FileNode, Buffer, Offset, EndOffset,
|
||||||
FileSystem, FileNode, Buffer, Offset, EndOffset, RequestHint);
|
FspFileSystemGetOperationContext()->Request->Hint).
|
||||||
Thread.detach();
|
detach();
|
||||||
|
return STATUS_PENDING;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
||||||
goto regular;
|
|
||||||
}
|
}
|
||||||
return STATUS_PENDING;
|
|
||||||
}
|
}
|
||||||
regular:
|
|
||||||
SlowioSnooze(FileSystem);
|
SlowioSnooze(FileSystem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1241,22 +1241,20 @@ static NTSTATUS Write(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
if (SlowioReturnPending(FileSystem))
|
if (SlowioReturnPending(FileSystem))
|
||||||
{
|
{
|
||||||
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspFileSystemGetOperationContext()->Request;
|
try
|
||||||
UINT64 RequestHint = Request->Hint;
|
{
|
||||||
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
||||||
try {
|
std::thread(SlowioWriteThread,
|
||||||
auto Thread = std::thread(SlowioWriteThread,
|
FileSystem, FileNode, Buffer, Offset, EndOffset,
|
||||||
FileSystem, FileNode, Buffer, Offset, EndOffset, RequestHint);
|
FspFileSystemGetOperationContext()->Request->Hint).
|
||||||
Thread.detach();
|
detach();
|
||||||
|
return STATUS_PENDING;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
||||||
goto regular;
|
|
||||||
}
|
}
|
||||||
return STATUS_PENDING;
|
|
||||||
}
|
}
|
||||||
regular:
|
|
||||||
SlowioSnooze(FileSystem);
|
SlowioSnooze(FileSystem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1632,22 +1630,20 @@ static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
#ifdef MEMFS_SLOWIO
|
#ifdef MEMFS_SLOWIO
|
||||||
if (SlowioReturnPending(FileSystem))
|
if (SlowioReturnPending(FileSystem))
|
||||||
{
|
{
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspFileSystemGetOperationContext()->Request;
|
try
|
||||||
UINT64 RequestHint = Request->Hint;
|
{
|
||||||
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
InterlockedIncrement(&Memfs->SlowioThreadsRunning);
|
||||||
try {
|
std::thread(SlowioReadDirectoryThread,
|
||||||
auto Thread = std::thread(SlowioReadDirectoryThread,
|
FileSystem, *PBytesTransferred,
|
||||||
FileSystem, *PBytesTransferred, RequestHint);
|
FspFileSystemGetOperationContext()->Request->Hint).
|
||||||
Thread.detach();
|
detach();
|
||||||
|
return STATUS_PENDING;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
InterlockedDecrement(&Memfs->SlowioThreadsRunning);
|
||||||
goto regular;
|
|
||||||
}
|
}
|
||||||
return STATUS_PENDING;
|
|
||||||
}
|
}
|
||||||
regular:
|
|
||||||
SlowioSnooze(FileSystem);
|
SlowioSnooze(FileSystem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user