diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 35a0711..8dd96d6 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -57,9 +57,6 @@ namespace OpenMetaverse | |||
57 | /// <summary>UDP socket, used in either client or server mode</summary> | 57 | /// <summary>UDP socket, used in either client or server mode</summary> |
58 | private Socket m_udpSocket; | 58 | private Socket m_udpSocket; |
59 | 59 | ||
60 | /// <summary>Flag to process packets asynchronously or synchronously</summary> | ||
61 | private bool m_asyncPacketHandling; | ||
62 | |||
63 | /// <summary> | 60 | /// <summary> |
64 | /// Are we to use object pool(s) to reduce memory churn when receiving data? | 61 | /// Are we to use object pool(s) to reduce memory churn when receiving data? |
65 | /// </summary> | 62 | /// </summary> |
@@ -205,10 +202,8 @@ namespace OpenMetaverse | |||
205 | /// manner (not throwing an exception when the remote side resets the | 202 | /// manner (not throwing an exception when the remote side resets the |
206 | /// connection). This call is ignored on Mono where the flag is not | 203 | /// connection). This call is ignored on Mono where the flag is not |
207 | /// necessary</remarks> | 204 | /// necessary</remarks> |
208 | public virtual void StartInbound(int recvBufferSize, bool asyncPacketHandling) | 205 | public virtual void StartInbound(int recvBufferSize) |
209 | { | 206 | { |
210 | m_asyncPacketHandling = asyncPacketHandling; | ||
211 | |||
212 | if (!IsRunningInbound) | 207 | if (!IsRunningInbound) |
213 | { | 208 | { |
214 | m_log.DebugFormat("[UDPBASE]: Starting inbound UDP loop"); | 209 | m_log.DebugFormat("[UDPBASE]: Starting inbound UDP loop"); |
@@ -407,12 +402,7 @@ namespace OpenMetaverse | |||
407 | if (IsRunningInbound) | 402 | if (IsRunningInbound) |
408 | { | 403 | { |
409 | UdpReceives++; | 404 | UdpReceives++; |
410 | 405 | ||
411 | // Asynchronous mode will start another receive before the | ||
412 | // callback for this packet is even fired. Very parallel :-) | ||
413 | if (m_asyncPacketHandling) | ||
414 | AsyncBeginReceive(); | ||
415 | |||
416 | try | 406 | try |
417 | { | 407 | { |
418 | // get the buffer that was created in AsyncBeginReceive | 408 | // get the buffer that was created in AsyncBeginReceive |
@@ -469,10 +459,7 @@ namespace OpenMetaverse | |||
469 | // if (UsePools) | 459 | // if (UsePools) |
470 | // Pool.ReturnObject(buffer); | 460 | // Pool.ReturnObject(buffer); |
471 | 461 | ||
472 | // Synchronous mode waits until the packet callback completes | 462 | AsyncBeginReceive(); |
473 | // before starting the receive to fetch another packet | ||
474 | if (!m_asyncPacketHandling) | ||
475 | AsyncBeginReceive(); | ||
476 | } | 463 | } |
477 | } | 464 | } |
478 | } | 465 | } |
@@ -500,7 +487,7 @@ namespace OpenMetaverse | |||
500 | } | 487 | } |
501 | catch (SocketException) { } | 488 | catch (SocketException) { } |
502 | catch (ObjectDisposedException) { } | 489 | catch (ObjectDisposedException) { } |
503 | // } | 490 | // } |
504 | } | 491 | } |
505 | 492 | ||
506 | void AsyncEndSend(IAsyncResult result) | 493 | void AsyncEndSend(IAsyncResult result) |
@@ -515,5 +502,25 @@ namespace OpenMetaverse | |||
515 | catch (SocketException) { } | 502 | catch (SocketException) { } |
516 | catch (ObjectDisposedException) { } | 503 | catch (ObjectDisposedException) { } |
517 | } | 504 | } |
505 | |||
506 | public void SyncSend(UDPPacketBuffer buf) | ||
507 | { | ||
508 | try | ||
509 | { | ||
510 | m_udpSocket.SendTo( | ||
511 | buf.Data, | ||
512 | 0, | ||
513 | buf.DataLength, | ||
514 | SocketFlags.None, | ||
515 | buf.RemoteEndPoint | ||
516 | ); | ||
517 | UdpSends++; | ||
518 | } | ||
519 | catch (SocketException e) | ||
520 | { | ||
521 | m_log.Warn("[UDPBASE]: sync send SocketException {0} " + e.Message); | ||
522 | } | ||
523 | catch (ObjectDisposedException) { } | ||
524 | } | ||
518 | } | 525 | } |
519 | } | 526 | } |