diff options
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/UDPServer.cs | 79 |
2 files changed, 72 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index c9a71bd..5c179be 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -476,6 +476,7 @@ namespace OpenSim.Region.ClientStack | |||
476 | { | 476 | { |
477 | //session/circuit not authorised | 477 | //session/circuit not authorised |
478 | m_log.Info("[CLIENT]: New user request denied to " + m_userEndPoint.ToString()); | 478 | m_log.Info("[CLIENT]: New user request denied to " + m_userEndPoint.ToString()); |
479 | m_packetQueue.Flush(); | ||
479 | m_packetQueue.Close(); | 480 | m_packetQueue.Close(); |
480 | m_clientThread.Abort(); | 481 | m_clientThread.Abort(); |
481 | } | 482 | } |
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 0a301b5..73f2ac1 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs | |||
@@ -111,7 +111,7 @@ namespace OpenSim.Region.ClientStack | |||
111 | epSender = (EndPoint) ipeSender; | 111 | epSender = (EndPoint) ipeSender; |
112 | Packet packet = null; | 112 | Packet packet = null; |
113 | 113 | ||
114 | int numBytes; | 114 | int numBytes = 1; |
115 | 115 | ||
116 | try | 116 | try |
117 | { | 117 | { |
@@ -173,8 +173,9 @@ namespace OpenSim.Region.ClientStack | |||
173 | // Stupid I know.. | 173 | // Stupid I know.. |
174 | // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. | 174 | // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. |
175 | } | 175 | } |
176 | catch (SocketException) | 176 | catch (SocketException e2) |
177 | { | 177 | { |
178 | m_log.Error("[UDPSERVER]: " + e2.ToString()); | ||
178 | } | 179 | } |
179 | 180 | ||
180 | // Here's some reference code! :D | 181 | // Here's some reference code! :D |
@@ -187,12 +188,28 @@ namespace OpenSim.Region.ClientStack | |||
187 | break; | 188 | break; |
188 | } | 189 | } |
189 | 190 | ||
190 | return; | 191 | //return; |
191 | } | 192 | } |
192 | catch (ObjectDisposedException e) | 193 | catch (ObjectDisposedException e) |
193 | { | 194 | { |
194 | m_log.Debug("[UDPSERVER]: " + e.ToString()); | 195 | m_log.Debug("[UDPSERVER]: " + e.ToString()); |
195 | return; | 196 | try |
197 | { | ||
198 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, | ||
199 | ReceivedData, null); | ||
200 | |||
201 | // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. | ||
202 | // so therefore.. we've got to tell the server to BeginReceiveFrom again. | ||
203 | // This will happen over and over until we've gone through all packets | ||
204 | // sent to and from this particular user. | ||
205 | // Stupid I know.. | ||
206 | // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. | ||
207 | } | ||
208 | catch (SocketException e2) | ||
209 | { | ||
210 | m_log.Error("[UDPSERVER]: " + e2.ToString()); | ||
211 | } | ||
212 | //return; | ||
196 | } | 213 | } |
197 | 214 | ||
198 | int packetEnd = numBytes - 1; | 215 | int packetEnd = numBytes - 1; |
@@ -221,7 +238,16 @@ namespace OpenSim.Region.ClientStack | |||
221 | { | 238 | { |
222 | // new client | 239 | // new client |
223 | m_log.Debug("[UDPSERVER]: Adding New Client"); | 240 | m_log.Debug("[UDPSERVER]: Adding New Client"); |
224 | AddNewClient(packet); | 241 | try |
242 | { | ||
243 | AddNewClient(packet); | ||
244 | } | ||
245 | catch (Exception e3) | ||
246 | { | ||
247 | m_log.Error("[UDPSERVER]: Adding New Client threw exception " + e3.ToString()); | ||
248 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, | ||
249 | ReceivedData, null); | ||
250 | } | ||
225 | } | 251 | } |
226 | else | 252 | else |
227 | { | 253 | { |
@@ -231,8 +257,38 @@ namespace OpenSim.Region.ClientStack | |||
231 | 257 | ||
232 | } | 258 | } |
233 | } | 259 | } |
260 | try | ||
261 | { | ||
262 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
263 | } | ||
264 | catch (SocketException e4) | ||
265 | { | ||
266 | try | ||
267 | { | ||
268 | CloseEndPoint(epSender); | ||
269 | } | ||
270 | catch (Exception a) | ||
271 | { | ||
272 | m_log.Info("[UDPSERVER]: " + a.ToString()); | ||
273 | } | ||
274 | try | ||
275 | { | ||
276 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, | ||
277 | ReceivedData, null); | ||
278 | |||
279 | // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. | ||
280 | // so therefore.. we've got to tell the server to BeginReceiveFrom again. | ||
281 | // This will happen over and over until we've gone through all packets | ||
282 | // sent to and from this particular user. | ||
283 | // Stupid I know.. | ||
284 | // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. | ||
285 | } | ||
286 | catch (SocketException e5) | ||
287 | { | ||
288 | m_log.Error("[UDPSERVER]: " + e5.ToString()); | ||
289 | } | ||
234 | 290 | ||
235 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 291 | } |
236 | } | 292 | } |
237 | 293 | ||
238 | private void CloseEndPoint(EndPoint sender) | 294 | private void CloseEndPoint(EndPoint sender) |
@@ -247,8 +303,15 @@ namespace OpenSim.Region.ClientStack | |||
247 | protected virtual void AddNewClient(Packet packet) | 303 | protected virtual void AddNewClient(Packet packet) |
248 | { | 304 | { |
249 | UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; | 305 | UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; |
250 | clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); | 306 | lock (clientCircuits) |
251 | clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); | 307 | { |
308 | clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); | ||
309 | } | ||
310 | lock (clientCircuits_reverse) | ||
311 | { | ||
312 | if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) | ||
313 | clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); | ||
314 | } | ||
252 | 315 | ||
253 | PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); | 316 | PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); |
254 | } | 317 | } |