mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-23 23:40:47 +02:00
Improved SID (search handle) allocation mechanism
This commit is contained in:
parent
86c50e45fd
commit
b12a340d70
2 changed files with 20 additions and 13 deletions
|
@ -270,15 +270,22 @@ namespace SMBLibrary.Server
|
|||
}
|
||||
}
|
||||
|
||||
public ushort AllocateSearchHandle()
|
||||
public ushort? AllocateSearchHandle()
|
||||
{
|
||||
while (OpenSearches.ContainsKey(m_nextSearchHandle) || m_nextSearchHandle == 0 || m_nextSearchHandle == 0xFFFF)
|
||||
for (ushort offset = 0; offset < UInt16.MaxValue; offset++)
|
||||
{
|
||||
m_nextSearchHandle++;
|
||||
ushort searchHandle = (ushort)(m_nextSearchHandle + offset);
|
||||
if (searchHandle == 0 || searchHandle == 0xFFFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!OpenSearches.ContainsKey(searchHandle))
|
||||
{
|
||||
m_nextSearchHandle = (ushort)(searchHandle + 1);
|
||||
return searchHandle;
|
||||
}
|
||||
}
|
||||
ushort searchHandle = m_nextSearchHandle;
|
||||
m_nextSearchHandle++;
|
||||
return searchHandle;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ReleaseSearchHandle(ushort searchHandle)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue