|
@@ -85,14 +85,17 @@ namespace SMBLibrary.Server
|
|
|
m_connectedTrees.TryGetValue(treeID, out share);
|
|
|
if (share != null)
|
|
|
{
|
|
|
- List<ulong> fileIDList = new List<ulong>(m_openFiles.Keys);
|
|
|
- foreach (ushort fileID in fileIDList)
|
|
|
+ lock (m_openFiles)
|
|
|
{
|
|
|
- OpenFileObject openFile = m_openFiles[fileID];
|
|
|
- if (openFile.TreeID == treeID)
|
|
|
+ List<ulong> fileIDList = new List<ulong>(m_openFiles.Keys);
|
|
|
+ foreach (ushort fileID in fileIDList)
|
|
|
{
|
|
|
- share.FileStore.CloseFile(openFile.Handle);
|
|
|
- m_openFiles.Remove(fileID);
|
|
|
+ OpenFileObject openFile = m_openFiles[fileID];
|
|
|
+ if (openFile.TreeID == treeID)
|
|
|
+ {
|
|
|
+ share.FileStore.CloseFile(openFile.Handle);
|
|
|
+ m_openFiles.Remove(fileID);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
m_connectedTrees.Remove(treeID);
|
|
@@ -110,7 +113,10 @@ namespace SMBLibrary.Server
|
|
|
ulong? persistentID = m_connection.AllocatePersistentFileID();
|
|
|
if (persistentID.HasValue)
|
|
|
{
|
|
|
- m_openFiles.Add(persistentID.Value, new OpenFileObject(treeID, relativePath, handle));
|
|
|
+ lock (m_openFiles)
|
|
|
+ {
|
|
|
+ m_openFiles.Add(persistentID.Value, new OpenFileObject(treeID, relativePath, handle));
|
|
|
+ }
|
|
|
}
|
|
|
return persistentID;
|
|
|
}
|
|
@@ -129,10 +135,26 @@ namespace SMBLibrary.Server
|
|
|
|
|
|
public void RemoveOpenFile(ulong fileID)
|
|
|
{
|
|
|
- m_openFiles.Remove(fileID);
|
|
|
+ lock (m_openFiles)
|
|
|
+ {
|
|
|
+ m_openFiles.Remove(fileID);
|
|
|
+ }
|
|
|
m_openSearches.Remove(fileID);
|
|
|
}
|
|
|
|
|
|
+ public List<string> ListOpenFiles()
|
|
|
+ {
|
|
|
+ List<string> result = new List<string>();
|
|
|
+ lock (m_openFiles)
|
|
|
+ {
|
|
|
+ foreach (OpenFileObject openFile in m_openFiles.Values)
|
|
|
+ {
|
|
|
+ result.Add(openFile.Path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public OpenSearch AddOpenSearch(ulong fileID, List<QueryDirectoryFileInformation> entries, int enumerationLocation)
|
|
|
{
|
|
|
OpenSearch openSearch = new OpenSearch(entries, enumerationLocation);
|