diff options
author | Justin Clark-Casey (justincc) | 2012-10-16 21:55:00 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-16 21:55:00 +0100 |
commit | db4ca57590db44aba7d19530285091c7ea4c082c (patch) | |
tree | 48ab213b481e9b67ae193d9d811378f599f9ad65 /OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |
parent | minor: Comment out log message on every FRIENDS SIM CONNECTOR request for now. (diff) | |
download | opensim-SC_OLD-db4ca57590db44aba7d19530285091c7ea4c082c.zip opensim-SC_OLD-db4ca57590db44aba7d19530285091c7ea4c082c.tar.gz opensim-SC_OLD-db4ca57590db44aba7d19530285091c7ea4c082c.tar.bz2 opensim-SC_OLD-db4ca57590db44aba7d19530285091c7ea4c082c.tar.xz |
Make it possible to separate start and stop lludp packet processing from the console for debug processes.
This is controlled via the "debug lludp start <in|out|all>" and "debug lludp stop <in|out|all>" region console commands.
The command "debug lludp status" will show current status.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 039379d..828c23c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -58,11 +58,12 @@ namespace OpenMetaverse | |||
58 | /// <summary>Flag to process packets asynchronously or synchronously</summary> | 58 | /// <summary>Flag to process packets asynchronously or synchronously</summary> |
59 | private bool m_asyncPacketHandling; | 59 | private bool m_asyncPacketHandling; |
60 | 60 | ||
61 | /// <summary>The all important shutdown flag</summary> | 61 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> |
62 | private volatile bool m_shutdownFlag = true; | 62 | public bool IsRunningInbound { get; private set; } |
63 | 63 | ||
64 | /// <summary>Returns true if the server is currently listening, otherwise false</summary> | 64 | /// <summary>Returns true if the server is currently sending outbound packets, otherwise false</summary> |
65 | public bool IsRunning { get { return !m_shutdownFlag; } } | 65 | /// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks> |
66 | public bool IsRunningOutbound { get; private set; } | ||
66 | 67 | ||
67 | /// <summary> | 68 | /// <summary> |
68 | /// Default constructor | 69 | /// Default constructor |
@@ -76,7 +77,7 @@ namespace OpenMetaverse | |||
76 | } | 77 | } |
77 | 78 | ||
78 | /// <summary> | 79 | /// <summary> |
79 | /// Start the UDP server | 80 | /// Start inbound UDP packet handling. |
80 | /// </summary> | 81 | /// </summary> |
81 | /// <param name="recvBufferSize">The size of the receive buffer for | 82 | /// <param name="recvBufferSize">The size of the receive buffer for |
82 | /// the UDP socket. This value is passed up to the operating system | 83 | /// the UDP socket. This value is passed up to the operating system |
@@ -91,11 +92,11 @@ namespace OpenMetaverse | |||
91 | /// manner (not throwing an exception when the remote side resets the | 92 | /// manner (not throwing an exception when the remote side resets the |
92 | /// connection). This call is ignored on Mono where the flag is not | 93 | /// connection). This call is ignored on Mono where the flag is not |
93 | /// necessary</remarks> | 94 | /// necessary</remarks> |
94 | public void Start(int recvBufferSize, bool asyncPacketHandling) | 95 | public void StartInbound(int recvBufferSize, bool asyncPacketHandling) |
95 | { | 96 | { |
96 | m_asyncPacketHandling = asyncPacketHandling; | 97 | m_asyncPacketHandling = asyncPacketHandling; |
97 | 98 | ||
98 | if (m_shutdownFlag) | 99 | if (!IsRunningInbound) |
99 | { | 100 | { |
100 | const int SIO_UDP_CONNRESET = -1744830452; | 101 | const int SIO_UDP_CONNRESET = -1744830452; |
101 | 102 | ||
@@ -127,8 +128,7 @@ namespace OpenMetaverse | |||
127 | 128 | ||
128 | m_udpSocket.Bind(ipep); | 129 | m_udpSocket.Bind(ipep); |
129 | 130 | ||
130 | // we're not shutting down, we're starting up | 131 | IsRunningInbound = true; |
131 | m_shutdownFlag = false; | ||
132 | 132 | ||
133 | // kick off an async receive. The Start() method will return, the | 133 | // kick off an async receive. The Start() method will return, the |
134 | // actual receives will occur asynchronously and will be caught in | 134 | // actual receives will occur asynchronously and will be caught in |
@@ -138,28 +138,38 @@ namespace OpenMetaverse | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /// <summary> | 140 | /// <summary> |
141 | /// Stops the UDP server | 141 | /// Start outbound UDP packet handling. |
142 | /// </summary> | 142 | /// </summary> |
143 | public void Stop() | 143 | public void StartOutbound() |
144 | { | 144 | { |
145 | if (!m_shutdownFlag) | 145 | IsRunningOutbound = true; |
146 | } | ||
147 | |||
148 | public void StopInbound() | ||
149 | { | ||
150 | if (IsRunningInbound) | ||
146 | { | 151 | { |
147 | // wait indefinitely for a writer lock. Once this is called, the .NET runtime | 152 | // wait indefinitely for a writer lock. Once this is called, the .NET runtime |
148 | // will deny any more reader locks, in effect blocking all other send/receive | 153 | // will deny any more reader locks, in effect blocking all other send/receive |
149 | // threads. Once we have the lock, we set shutdownFlag to inform the other | 154 | // threads. Once we have the lock, we set IsRunningInbound = false to inform the other |
150 | // threads that the socket is closed. | 155 | // threads that the socket is closed. |
151 | m_shutdownFlag = true; | 156 | IsRunningInbound = false; |
152 | m_udpSocket.Close(); | 157 | m_udpSocket.Close(); |
153 | } | 158 | } |
154 | } | 159 | } |
155 | 160 | ||
161 | public void StopOutbound() | ||
162 | { | ||
163 | IsRunningOutbound = false; | ||
164 | } | ||
165 | |||
156 | private void AsyncBeginReceive() | 166 | private void AsyncBeginReceive() |
157 | { | 167 | { |
158 | // allocate a packet buffer | 168 | // allocate a packet buffer |
159 | //WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut(); | 169 | //WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut(); |
160 | UDPPacketBuffer buf = new UDPPacketBuffer(); | 170 | UDPPacketBuffer buf = new UDPPacketBuffer(); |
161 | 171 | ||
162 | if (!m_shutdownFlag) | 172 | if (IsRunningInbound) |
163 | { | 173 | { |
164 | try | 174 | try |
165 | { | 175 | { |
@@ -212,7 +222,7 @@ namespace OpenMetaverse | |||
212 | { | 222 | { |
213 | // Asynchronous receive operations will complete here through the call | 223 | // Asynchronous receive operations will complete here through the call |
214 | // to AsyncBeginReceive | 224 | // to AsyncBeginReceive |
215 | if (!m_shutdownFlag) | 225 | if (IsRunningInbound) |
216 | { | 226 | { |
217 | // Asynchronous mode will start another receive before the | 227 | // Asynchronous mode will start another receive before the |
218 | // callback for this packet is even fired. Very parallel :-) | 228 | // callback for this packet is even fired. Very parallel :-) |
@@ -252,7 +262,7 @@ namespace OpenMetaverse | |||
252 | 262 | ||
253 | public void AsyncBeginSend(UDPPacketBuffer buf) | 263 | public void AsyncBeginSend(UDPPacketBuffer buf) |
254 | { | 264 | { |
255 | if (!m_shutdownFlag) | 265 | if (IsRunningOutbound) |
256 | { | 266 | { |
257 | try | 267 | try |
258 | { | 268 | { |