mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-16 01:17:03 +02:00
Server: Maintain connection last send time
This commit is contained in:
parent
765443591f
commit
bb8cadee93
4 changed files with 62 additions and 0 deletions
|
@ -24,6 +24,7 @@ namespace SMBLibrary.Server
|
||||||
private BlockingQueue<SessionPacket> m_sendQueue;
|
private BlockingQueue<SessionPacket> m_sendQueue;
|
||||||
private DateTime m_creationDT;
|
private DateTime m_creationDT;
|
||||||
private DateTime m_lastReceiveDT;
|
private DateTime m_lastReceiveDT;
|
||||||
|
private Reference<DateTime> m_lastSendDTRef; // We must use a reference because the sender thread will keep using the original ConnectionState object
|
||||||
private LogDelegate LogToServerHandler;
|
private LogDelegate LogToServerHandler;
|
||||||
public SMBDialect Dialect;
|
public SMBDialect Dialect;
|
||||||
public GSSContext AuthenticationContext;
|
public GSSContext AuthenticationContext;
|
||||||
|
@ -36,6 +37,7 @@ namespace SMBLibrary.Server
|
||||||
m_sendQueue = new BlockingQueue<SessionPacket>();
|
m_sendQueue = new BlockingQueue<SessionPacket>();
|
||||||
m_creationDT = DateTime.UtcNow;
|
m_creationDT = DateTime.UtcNow;
|
||||||
m_lastReceiveDT = DateTime.UtcNow;
|
m_lastReceiveDT = DateTime.UtcNow;
|
||||||
|
m_lastSendDTRef = DateTime.UtcNow;
|
||||||
LogToServerHandler = logToServerHandler;
|
LogToServerHandler = logToServerHandler;
|
||||||
Dialect = SMBDialect.NotSet;
|
Dialect = SMBDialect.NotSet;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +50,7 @@ namespace SMBLibrary.Server
|
||||||
m_sendQueue = state.SendQueue;
|
m_sendQueue = state.SendQueue;
|
||||||
m_creationDT = state.CreationDT;
|
m_creationDT = state.CreationDT;
|
||||||
m_lastReceiveDT = state.LastReceiveDT;
|
m_lastReceiveDT = state.LastReceiveDT;
|
||||||
|
m_lastSendDTRef = state.LastSendDTRef;
|
||||||
LogToServerHandler = state.LogToServerHandler;
|
LogToServerHandler = state.LogToServerHandler;
|
||||||
Dialect = state.Dialect;
|
Dialect = state.Dialect;
|
||||||
}
|
}
|
||||||
|
@ -126,11 +129,32 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime LastSendDT
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return LastSendDTRef.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Reference<DateTime> LastSendDTRef
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_lastSendDTRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateLastReceiveDT()
|
public void UpdateLastReceiveDT()
|
||||||
{
|
{
|
||||||
m_lastReceiveDT = DateTime.UtcNow;
|
m_lastReceiveDT = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateLastSendDT()
|
||||||
|
{
|
||||||
|
m_lastSendDTRef.Value = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
public string ConnectionIdentifier
|
public string ConnectionIdentifier
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -399,6 +399,7 @@ namespace SMBLibrary.Server
|
||||||
m_connectionManager.ReleaseConnection(state.ClientEndPoint);
|
m_connectionManager.ReleaseConnection(state.ClientEndPoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
state.UpdateLastSendDT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
Utilities/Generics/Reference.cs
Normal file
36
Utilities/Generics/Reference.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Utilities
|
||||||
|
{
|
||||||
|
public class Reference<T> where T : struct
|
||||||
|
{
|
||||||
|
T m_value;
|
||||||
|
|
||||||
|
public Reference(T value)
|
||||||
|
{
|
||||||
|
m_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Value
|
||||||
|
{
|
||||||
|
get { return m_value; }
|
||||||
|
set { m_value = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return m_value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator T(Reference<T> wrapper)
|
||||||
|
{
|
||||||
|
return wrapper.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Reference<T>(T value)
|
||||||
|
{
|
||||||
|
return new Reference<T>(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,6 +46,7 @@
|
||||||
<Compile Include="Generics\BlockingQueue.cs" />
|
<Compile Include="Generics\BlockingQueue.cs" />
|
||||||
<Compile Include="Generics\KeyValuePairList.cs" />
|
<Compile Include="Generics\KeyValuePairList.cs" />
|
||||||
<Compile Include="Generics\Map.cs" />
|
<Compile Include="Generics\Map.cs" />
|
||||||
|
<Compile Include="Generics\Reference.cs" />
|
||||||
<Compile Include="Generics\SortedList.cs" />
|
<Compile Include="Generics\SortedList.cs" />
|
||||||
<Compile Include="IFileSystem\FileSystem.cs" />
|
<Compile Include="IFileSystem\FileSystem.cs" />
|
||||||
<Compile Include="IFileSystem\FileSystemEntry.cs" />
|
<Compile Include="IFileSystem\FileSystemEntry.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue