* refactor: Split BeginRecieve() into BeginReceive() and BeginRobustReceive()
parent
5a852321e0
commit
d31d02c373
|
@ -231,7 +231,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginReceive();
|
BeginRobustReceive();
|
||||||
|
|
||||||
if (packet != null)
|
if (packet != null)
|
||||||
{
|
{
|
||||||
|
@ -279,12 +279,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
/// Begin an asynchronous receive of the next bit of raw data
|
/// Begin an asynchronous receive of the next bit of raw data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void BeginReceive()
|
protected virtual void BeginReceive()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
m_socket.BeginReceiveFrom(
|
m_socket.BeginReceiveFrom(
|
||||||
RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null);
|
RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begin a robust asynchronous receive of the next bit of raw data. Robust means that SocketExceptions are
|
||||||
|
/// automatically dealt with until the next set of valid UDP data is received.
|
||||||
|
/// </summary>
|
||||||
|
private void BeginRobustReceive()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BeginReceive();
|
||||||
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
// ENDLESS LOOP ON PURPOSE!
|
// ENDLESS LOOP ON PURPOSE!
|
||||||
|
@ -301,7 +310,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
/// <param name="e">
|
/// <param name="e">
|
||||||
/// The exception that has triggered the reset. Can be null if there was no exception.
|
/// The exception that has triggered the reset. Can be null if there was no exception.
|
||||||
/// </param>
|
/// </param>
|
||||||
protected void ResetServerEndPoint(Exception e)
|
private void ResetServerEndPoint(Exception e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -315,8 +324,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
// ENDLESS LOOP ON PURPOSE!
|
// ENDLESS LOOP ON PURPOSE!
|
||||||
// We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die
|
// We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die
|
||||||
// The only way to do that is to beginreceive again!
|
// The only way to do that is to BeginRobustReceive again!
|
||||||
BeginReceive();
|
BeginRobustReceive();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -470,8 +479,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen");
|
m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen");
|
||||||
|
|
||||||
ReceivedData = OnReceivedData;
|
ReceivedData = OnReceivedData;
|
||||||
m_socket.BeginReceiveFrom(
|
BeginReceive();
|
||||||
RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null);
|
|
||||||
|
|
||||||
m_log.Info("[UDPSERVER]: Listening on port " + newPort);
|
m_log.Info("[UDPSERVER]: Listening on port " + newPort);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
{
|
{
|
||||||
ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
||||||
reusedEpSender = tuple.Sender;
|
reusedEpSender = tuple.Sender;
|
||||||
ResetServerEndPoint(new SocketException());
|
throw new SocketException();
|
||||||
ReceiveData(null);
|
ReceiveData(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue