mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-09 13:32:14 -05:00
sys: FspFileNodeFlushAndPurgeCache: wrap Cc* calls in try/except
This commit is contained in:
parent
b734e6968d
commit
15f39c3ca8
@ -545,7 +545,7 @@ NTSTATUS FspFileNodeFlushAndPurgeCache(FSP_FILE_NODE *FileNode,
|
|||||||
LARGE_INTEGER FlushOffset;
|
LARGE_INTEGER FlushOffset;
|
||||||
PLARGE_INTEGER PFlushOffset = &FlushOffset;
|
PLARGE_INTEGER PFlushOffset = &FlushOffset;
|
||||||
FSP_FSCTL_FILE_INFO FileInfo;
|
FSP_FSCTL_FILE_INFO FileInfo;
|
||||||
IO_STATUS_BLOCK IoStatus = { 0 };
|
IO_STATUS_BLOCK IoStatus = { STATUS_SUCCESS };
|
||||||
|
|
||||||
FlushOffset.QuadPart = FlushOffset64;
|
FlushOffset.QuadPart = FlushOffset64;
|
||||||
if (FILE_WRITE_TO_END_OF_FILE == FlushOffset.LowPart && -1L == FlushOffset.HighPart)
|
if (FILE_WRITE_TO_END_OF_FILE == FlushOffset.LowPart && -1L == FlushOffset.HighPart)
|
||||||
@ -556,6 +556,9 @@ NTSTATUS FspFileNodeFlushAndPurgeCache(FSP_FILE_NODE *FileNode,
|
|||||||
PFlushOffset = 0; /* we don't know how big the file is, so flush it all! */
|
PFlushOffset = 0; /* we don't know how big the file is, so flush it all! */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* it is unclear if the Cc* calls below can raise or not; wrap them just in case */
|
||||||
|
try
|
||||||
|
{
|
||||||
if (0 != FspMvCcCoherencyFlushAndPurgeCache)
|
if (0 != FspMvCcCoherencyFlushAndPurgeCache)
|
||||||
{
|
{
|
||||||
/* if we are on Win7+ use CcCoherencyFlushAndPurgeCache */
|
/* if we are on Win7+ use CcCoherencyFlushAndPurgeCache */
|
||||||
@ -563,22 +566,28 @@ NTSTATUS FspFileNodeFlushAndPurgeCache(FSP_FILE_NODE *FileNode,
|
|||||||
&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, &IoStatus,
|
&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, &IoStatus,
|
||||||
FlushAndPurge ? 0 : CC_FLUSH_AND_PURGE_NO_PURGE);
|
FlushAndPurge ? 0 : CC_FLUSH_AND_PURGE_NO_PURGE);
|
||||||
|
|
||||||
return STATUS_CACHE_PAGE_LOCKED == IoStatus.Status ?
|
if (STATUS_CACHE_PAGE_LOCKED == IoStatus.Status)
|
||||||
STATUS_SUCCESS/* liar! */:
|
IoStatus.Status = STATUS_SUCCESS;
|
||||||
IoStatus.Status;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* do it the old-fashioned way; non-cached and mmap'ed I/O are non-coherent */
|
/* do it the old-fashioned way; non-cached and mmap'ed I/O are non-coherent */
|
||||||
CcFlushCache(&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, &IoStatus);
|
CcFlushCache(&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, &IoStatus);
|
||||||
if (!NT_SUCCESS(IoStatus.Status))
|
if (NT_SUCCESS(IoStatus.Status))
|
||||||
return IoStatus.Status;
|
{
|
||||||
|
|
||||||
if (FlushAndPurge)
|
if (FlushAndPurge)
|
||||||
CcPurgeCacheSection(&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, FALSE);
|
CcPurgeCacheSection(&FileNode->NonPaged->SectionObjectPointers, PFlushOffset, FlushLength, FALSE);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
IoStatus.Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
IoStatus.Status = GetExceptionCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FspFileNodeRename(FSP_FILE_NODE *FileNode, PUNICODE_STRING NewFileName)
|
VOID FspFileNodeRename(FSP_FILE_NODE *FileNode, PUNICODE_STRING NewFileName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user