aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/UDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/UDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs53
1 files changed, 48 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 55ef4a4..2b2269e 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -119,16 +119,48 @@ namespace OpenSim.Region.ClientStack
119 { 119 {
120 case SocketError.AlreadyInProgress: 120 case SocketError.AlreadyInProgress:
121 case SocketError.NetworkReset: 121 case SocketError.NetworkReset:
122 case SocketError.ConnectionReset:
123 try
124 {
125 CloseEndPoint(epSender);
126 }
127 catch (System.Exception a)
128 {
129 MainLog.Instance.Verbose("UDPSERVER", a.ToString());
130 }
131 try
132 {
133 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
134
135 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
136 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
137 // This will happen over and over until we've gone through all packets
138 // sent to and from this particular user.
139 // Stupid I know..
140 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
141
142 }
143 catch (SocketException)
144 {
145
146 }
147 break;
122 default: 148 default:
123 Console.WriteLine("Remote host Closed connection"); 149 // Here's some reference code! :D
124 CloseEndPoint(epSender); 150 // Shutdown and restart the UDP listener! hehe
151 // Shiny
152
153 //Server.Shutdown(SocketShutdown.Both);
154 //CloseEndPoint(epSender);
155 //ServerListener();
125 break; 156 break;
126 } 157 }
127 158
128 return; 159 return;
129 } 160 }
130 catch (System.ObjectDisposedException) 161 catch (System.ObjectDisposedException e)
131 { 162 {
163 MainLog.Instance.Debug("UDPSERVER", e.ToString());
132 return; 164 return;
133 } 165 }
134 166
@@ -138,8 +170,9 @@ namespace OpenSim.Region.ClientStack
138 { 170 {
139 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 171 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
140 } 172 }
141 catch(Exception) 173 catch(Exception e)
142 { 174 {
175 MainLog.Instance.Debug("UDPSERVER", e.ToString());
143 } 176 }
144 177
145 // do we already have a circuit for this endpoint 178 // do we already have a circuit for this endpoint
@@ -147,18 +180,21 @@ namespace OpenSim.Region.ClientStack
147 if (clientCircuits.TryGetValue(epSender, out circuit)) 180 if (clientCircuits.TryGetValue(epSender, out circuit))
148 { 181 {
149 //if so then send packet to the packetserver 182 //if so then send packet to the packetserver
183 //MainLog.Instance.Warn("UDPSERVER", "ALREADY HAVE Circuit!");
150 m_packetServer.InPacket(circuit, packet); 184 m_packetServer.InPacket(circuit, packet);
151 } 185 }
152 else if (packet.Type == PacketType.UseCircuitCode) 186 else if (packet.Type == PacketType.UseCircuitCode)
153 { 187 {
154 // new client 188 // new client
189 MainLog.Instance.Debug("UDPSERVER", "Adding New Client");
155 AddNewClient(packet); 190 AddNewClient(packet);
156 } 191 }
157 else 192 else
158 { 193 {
194
159 // invalid client 195 // invalid client
160 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now 196 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
161 //CFK: m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); 197 //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString());
162 } 198 }
163 199
164 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 200 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
@@ -169,7 +205,9 @@ namespace OpenSim.Region.ClientStack
169 uint circuit; 205 uint circuit;
170 if (clientCircuits.TryGetValue(sender, out circuit)) 206 if (clientCircuits.TryGetValue(sender, out circuit))
171 { 207 {
208 MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosingCircuit");
172 m_packetServer.CloseCircuit(circuit); 209 m_packetServer.CloseCircuit(circuit);
210 MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosedCircuit");
173 } 211 }
174 } 212 }
175 213
@@ -222,8 +260,13 @@ namespace OpenSim.Region.ClientStack
222 EndPoint sendto = null; 260 EndPoint sendto = null;
223 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 261 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
224 { 262 {
263 MainLog.Instance.Debug("UDPSERVER", "RemovingClientCircuit");
225 clientCircuits.Remove(sendto); 264 clientCircuits.Remove(sendto);
265 MainLog.Instance.Debug("UDPSERVER", "Removed Client Circuit");
266
267 MainLog.Instance.Debug("UDPSERVER", "Removing Reverse ClientCircuit");
226 clientCircuits_reverse.Remove(circuitcode); 268 clientCircuits_reverse.Remove(circuitcode);
269 MainLog.Instance.Debug("UDPSERVER", "Removed Reverse ClientCircuit");
227 } 270 }
228 } 271 }
229 } 272 }