diff options
author | Justin Clarke Casey | 2008-11-06 20:10:39 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-06 20:10:39 +0000 |
commit | d31d02c373f4cf0671a8c6269c2035a5741b83cf (patch) | |
tree | 7bf1295d4b9d5ac5e2e5f980b4a0f38b8f35c3f1 /OpenSim | |
parent | * Stop passing along epSender explicitly where we are really using the consta... (diff) | |
download | opensim-SC_OLD-d31d02c373f4cf0671a8c6269c2035a5741b83cf.zip opensim-SC_OLD-d31d02c373f4cf0671a8c6269c2035a5741b83cf.tar.gz opensim-SC_OLD-d31d02c373f4cf0671a8c6269c2035a5741b83cf.tar.bz2 opensim-SC_OLD-d31d02c373f4cf0671a8c6269c2035a5741b83cf.tar.xz |
* refactor: Split BeginRecieve() into BeginReceive() and BeginRobustReceive()
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs | 2 |
2 files changed, 19 insertions, 11 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index b9da83e..14d98d4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -231,7 +231,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | BeginReceive(); | 234 | BeginRobustReceive(); |
235 | 235 | ||
236 | if (packet != null) | 236 | if (packet != null) |
237 | { | 237 | { |
@@ -274,16 +274,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
274 | m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e); | 274 | m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | /// <summary> | 278 | /// <summary> |
279 | /// Begin an asynchronous receive of the next bit of raw data | 279 | /// Begin an asynchronous receive of the next bit of raw data |
280 | /// </summary> | 280 | /// </summary> |
281 | protected virtual void BeginReceive() | 281 | protected virtual void BeginReceive() |
282 | { | 282 | { |
283 | m_socket.BeginReceiveFrom( | ||
284 | RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); | ||
285 | } | ||
286 | |||
287 | /// <summary> | ||
288 | /// Begin a robust asynchronous receive of the next bit of raw data. Robust means that SocketExceptions are | ||
289 | /// automatically dealt with until the next set of valid UDP data is received. | ||
290 | /// </summary> | ||
291 | private void BeginRobustReceive() | ||
292 | { | ||
283 | try | 293 | try |
284 | { | 294 | { |
285 | m_socket.BeginReceiveFrom( | 295 | BeginReceive(); |
286 | RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); | ||
287 | } | 296 | } |
288 | catch (SocketException e) | 297 | catch (SocketException e) |
289 | { | 298 | { |
@@ -293,7 +302,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
293 | // the next set of UDP data is for a valid client. | 302 | // the next set of UDP data is for a valid client. |
294 | ResetServerEndPoint(e); | 303 | ResetServerEndPoint(e); |
295 | } | 304 | } |
296 | } | 305 | } |
297 | 306 | ||
298 | /// <summary> | 307 | /// <summary> |
299 | /// Reset the server endpoint | 308 | /// Reset the server endpoint |
@@ -301,7 +310,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
301 | /// <param name="e"> | 310 | /// <param name="e"> |
302 | /// The exception that has triggered the reset. Can be null if there was no exception. | 311 | /// The exception that has triggered the reset. Can be null if there was no exception. |
303 | /// </param> | 312 | /// </param> |
304 | protected void ResetServerEndPoint(Exception e) | 313 | private void ResetServerEndPoint(Exception e) |
305 | { | 314 | { |
306 | try | 315 | try |
307 | { | 316 | { |
@@ -315,8 +324,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
315 | 324 | ||
316 | // ENDLESS LOOP ON PURPOSE! | 325 | // ENDLESS LOOP ON PURPOSE! |
317 | // We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die | 326 | // We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die |
318 | // The only way to do that is to beginreceive again! | 327 | // The only way to do that is to BeginRobustReceive again! |
319 | BeginReceive(); | 328 | BeginRobustReceive(); |
320 | } | 329 | } |
321 | 330 | ||
322 | /// <summary> | 331 | /// <summary> |
@@ -470,8 +479,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
470 | m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); | 479 | m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); |
471 | 480 | ||
472 | ReceivedData = OnReceivedData; | 481 | ReceivedData = OnReceivedData; |
473 | m_socket.BeginReceiveFrom( | 482 | BeginReceive(); |
474 | RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); | ||
475 | 483 | ||
476 | m_log.Info("[UDPSERVER]: Listening on port " + newPort); | 484 | m_log.Info("[UDPSERVER]: Listening on port " + newPort); |
477 | } | 485 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs index 67b8f42..b5f065d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
52 | { | 52 | { |
53 | ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); | 53 | ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); |
54 | reusedEpSender = tuple.Sender; | 54 | reusedEpSender = tuple.Sender; |
55 | ResetServerEndPoint(new SocketException()); | 55 | throw new SocketException(); |
56 | ReceiveData(null); | 56 | ReceiveData(null); |
57 | } | 57 | } |
58 | } | 58 | } |