mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: memfs-dotnet: remove unnecessary OpenNodeSet
This commit is contained in:
parent
a6ff8a87de
commit
ddba49dbea
@ -20,6 +20,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
using Fsp;
|
using Fsp;
|
||||||
using VolumeInfo = Fsp.Interop.VolumeInfo;
|
using VolumeInfo = Fsp.Interop.VolumeInfo;
|
||||||
@ -191,7 +192,6 @@ namespace memfs
|
|||||||
Boolean CaseInsensitive, UInt32 MaxFileNodes, UInt32 MaxFileSize, String RootSddl)
|
Boolean CaseInsensitive, UInt32 MaxFileNodes, UInt32 MaxFileSize, String RootSddl)
|
||||||
{
|
{
|
||||||
this.FileNodeMap = new FileNodeMap(CaseInsensitive);
|
this.FileNodeMap = new FileNodeMap(CaseInsensitive);
|
||||||
this.OpenNodeSet = new HashSet<FileNode>();
|
|
||||||
this.MaxFileNodes = MaxFileNodes;
|
this.MaxFileNodes = MaxFileNodes;
|
||||||
this.MaxFileSize = MaxFileSize;
|
this.MaxFileSize = MaxFileSize;
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ namespace memfs
|
|||||||
}
|
}
|
||||||
FileNodeMap.Insert(FileNode);
|
FileNodeMap.Insert(FileNode);
|
||||||
|
|
||||||
InsertOpenNode(FileNode);
|
Interlocked.Increment(ref FileNode.OpenCount);
|
||||||
FileNode0 = FileNode;
|
FileNode0 = FileNode;
|
||||||
FileInfo = FileNode.GetFileInfo();
|
FileInfo = FileNode.GetFileInfo();
|
||||||
NormalizedName = FileNode.FileName;
|
NormalizedName = FileNode.FileName;
|
||||||
@ -359,7 +359,7 @@ namespace memfs
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertOpenNode(FileNode);
|
Interlocked.Increment(ref FileNode.OpenCount);
|
||||||
FileNode0 = FileNode;
|
FileNode0 = FileNode;
|
||||||
FileInfo = FileNode.GetFileInfo();
|
FileInfo = FileNode.GetFileInfo();
|
||||||
NormalizedName = FileNode.FileName;
|
NormalizedName = FileNode.FileName;
|
||||||
@ -381,17 +381,14 @@ namespace memfs
|
|||||||
Int32 Result;
|
Int32 Result;
|
||||||
|
|
||||||
List<String> StreamFileNames = new List<String>(FileNodeMap.GetStreamFileNames(FileNode));
|
List<String> StreamFileNames = new List<String>(FileNodeMap.GetStreamFileNames(FileNode));
|
||||||
lock (OpenNodeSet)
|
|
||||||
{
|
|
||||||
foreach (String StreamFileName in StreamFileNames)
|
foreach (String StreamFileName in StreamFileNames)
|
||||||
{
|
{
|
||||||
FileNode StreamNode = FileNodeMap.Get(StreamFileName);
|
FileNode StreamNode = FileNodeMap.Get(StreamFileName);
|
||||||
if (null == StreamNode)
|
if (null == StreamNode)
|
||||||
continue; /* should not happen */
|
continue; /* should not happen */
|
||||||
if (!OpenNodeSet.Contains(StreamNode))
|
if (0 == FileNode.OpenCount)
|
||||||
FileNodeMap.Remove(StreamNode);
|
FileNodeMap.Remove(StreamNode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Result = SetFileSizeInternal(FileNode, AllocationSize, true);
|
Result = SetFileSizeInternal(FileNode, AllocationSize, true);
|
||||||
if (0 > Result)
|
if (0 > Result)
|
||||||
@ -465,7 +462,7 @@ namespace memfs
|
|||||||
Object FileDesc)
|
Object FileDesc)
|
||||||
{
|
{
|
||||||
FileNode FileNode = (FileNode)FileNode0;
|
FileNode FileNode = (FileNode)FileNode0;
|
||||||
RemoveOpenNode(FileNode);
|
Interlocked.Decrement(ref FileNode.OpenCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Int32 Read(
|
public override Int32 Read(
|
||||||
@ -960,25 +957,7 @@ namespace memfs
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertOpenNode(FileNode FileNode)
|
|
||||||
{
|
|
||||||
lock (OpenNodeSet)
|
|
||||||
{
|
|
||||||
if (1 == ++FileNode.OpenCount)
|
|
||||||
OpenNodeSet.Add(FileNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void RemoveOpenNode(FileNode FileNode)
|
|
||||||
{
|
|
||||||
lock (OpenNodeSet)
|
|
||||||
{
|
|
||||||
if (0 == --FileNode.OpenCount)
|
|
||||||
OpenNodeSet.Remove(FileNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FileNodeMap FileNodeMap;
|
private FileNodeMap FileNodeMap;
|
||||||
private HashSet<FileNode> OpenNodeSet;
|
|
||||||
private UInt32 MaxFileNodes;
|
private UInt32 MaxFileNodes;
|
||||||
private UInt32 MaxFileSize;
|
private UInt32 MaxFileSize;
|
||||||
private String VolumeLabel;
|
private String VolumeLabel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user