aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/UDPServer.cs
diff options
context:
space:
mode:
authorJeff Ames2008-02-05 19:44:27 +0000
committerJeff Ames2008-02-05 19:44:27 +0000
commit6ed5283bc06a62f38eb517e67b975832b603bf61 (patch)
treee5f635018789b73a99ddeca0883a68368fa5eece /OpenSim/Region/ClientStack/UDPServer.cs
parentCut down on the number of packets sent during terraforming. Terraforming shou... (diff)
downloadopensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.zip
opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.gz
opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.bz2
opensim-SC-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.xz
Converted logging to use log4net.
Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs30
1 files changed, 14 insertions, 16 deletions
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 3e2b536..f9918ff 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -39,6 +39,8 @@ namespace OpenSim.Region.ClientStack
39{ 39{
40 public class UDPServer : ClientStackNetworkHandler 40 public class UDPServer : ClientStackNetworkHandler
41 { 41 {
42 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43
42 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
43 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>(); 45 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>();
44 public Socket Server; 46 public Socket Server;
@@ -56,7 +58,6 @@ namespace OpenSim.Region.ClientStack
56 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); 58 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
57 protected IScene m_localScene; 59 protected IScene m_localScene;
58 protected AssetCache m_assetCache; 60 protected AssetCache m_assetCache;
59 protected LogBase m_log;
60 protected AgentCircuitManager m_authenticateSessionsClass; 61 protected AgentCircuitManager m_authenticateSessionsClass;
61 62
62 public PacketServer PacketServer 63 public PacketServer PacketServer
@@ -84,13 +85,12 @@ namespace OpenSim.Region.ClientStack
84 { 85 {
85 } 86 }
86 87
87 public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) 88 public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass)
88 { 89 {
89 listenIP = _listenIP; 90 listenIP = _listenIP;
90 listenPort = port; 91 listenPort = port;
91 Allow_Alternate_Port = allow_alternate_port; 92 Allow_Alternate_Port = allow_alternate_port;
92 m_assetCache = assetCache; 93 m_assetCache = assetCache;
93 m_log = console;
94 m_authenticateSessionsClass = authenticateClass; 94 m_authenticateSessionsClass = authenticateClass;
95 CreatePacketServer(); 95 CreatePacketServer();
96 96
@@ -121,7 +121,7 @@ namespace OpenSim.Region.ClientStack
121 { 121 {
122 // TODO : Actually only handle those states that we have control over, re-throw everything else, 122 // TODO : Actually only handle those states that we have control over, re-throw everything else,
123 // TODO: implement cases as we encounter them. 123 // TODO: implement cases as we encounter them.
124 //m_log.Error("UDPSERVER", "Connection Error! - " + e.ToString()); 124 //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString());
125 switch (e.SocketErrorCode) 125 switch (e.SocketErrorCode)
126 { 126 {
127 case SocketError.AlreadyInProgress: 127 case SocketError.AlreadyInProgress:
@@ -134,7 +134,7 @@ namespace OpenSim.Region.ClientStack
134 } 134 }
135 catch (Exception a) 135 catch (Exception a)
136 { 136 {
137 MainLog.Instance.Verbose("UDPSERVER", a.ToString()); 137 m_log.Info("[UDPSERVER]: " + a.ToString());
138 } 138 }
139 try 139 try
140 { 140 {
@@ -159,7 +159,7 @@ namespace OpenSim.Region.ClientStack
159 } 159 }
160 catch (Exception) 160 catch (Exception)
161 { 161 {
162 //MainLog.Instance.Verbose("UDPSERVER", a.ToString()); 162 //m_log.Info("[UDPSERVER]" + a.ToString());
163 } 163 }
164 try 164 try
165 { 165 {
@@ -191,8 +191,7 @@ namespace OpenSim.Region.ClientStack
191 } 191 }
192 catch (ObjectDisposedException) 192 catch (ObjectDisposedException)
193 { 193 {
194 194 //m_log.Debug("[UDPSERVER]: " + e.ToString());
195 //MainLog.Instance.Debug("UDPSERVER", e.ToString());
196 return; 195 return;
197 } 196 }
198 197
@@ -214,20 +213,20 @@ namespace OpenSim.Region.ClientStack
214 if (clientCircuits.TryGetValue(epSender, out circuit)) 213 if (clientCircuits.TryGetValue(epSender, out circuit))
215 { 214 {
216 //if so then send packet to the packetserver 215 //if so then send packet to the packetserver
217 //MainLog.Instance.Warn("UDPSERVER", "ALREADY HAVE Circuit!"); 216 //m_log.Warn("[UDPSERVER]: ALREADY HAVE Circuit!");
218 m_packetServer.InPacket(circuit, packet); 217 m_packetServer.InPacket(circuit, packet);
219 } 218 }
220 else if (packet.Type == PacketType.UseCircuitCode) 219 else if (packet.Type == PacketType.UseCircuitCode)
221 { 220 {
222 // new client 221 // new client
223 MainLog.Instance.Debug("UDPSERVER", "Adding New Client"); 222 m_log.Debug("[UDPSERVER]: Adding New Client");
224 AddNewClient(packet); 223 AddNewClient(packet);
225 } 224 }
226 else 225 else
227 { 226 {
228 // invalid client 227 // invalid client
229 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now 228 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
230 //m_log.Warn("UDPSERVER", "Got a packet from an invalid client - " + packet.ToString()); 229 //m_log.Warn("[UDPSERVER]: Got a packet from an invalid client - " + packet.ToString());
231 230
232 } 231 }
233 } 232 }
@@ -255,12 +254,11 @@ namespace OpenSim.Region.ClientStack
255 254
256 public void ServerListener() 255 public void ServerListener()
257 { 256 {
258
259 uint newPort = listenPort; 257 uint newPort = listenPort;
260 for (uint i = 0; i < 20; i++) 258 for (uint i = 0; i < 20; i++)
261 { 259 {
262 newPort = listenPort + i; 260 newPort = listenPort + i;
263 m_log.Verbose("SERVER", "Opening UDP socket on " + listenIP.ToString() + " " + newPort + ".");// Allow alternate ports: " + Allow_Alternate_Port.ToString()); 261 m_log.Info("[SERVER]: Opening UDP socket on " + listenIP.ToString() + " " + newPort + ".");// Allow alternate ports: " + Allow_Alternate_Port.ToString());
264 try 262 try
265 { 263 {
266 ServerIncoming = new IPEndPoint(listenIP, (int) newPort); 264 ServerIncoming = new IPEndPoint(listenIP, (int) newPort);
@@ -276,19 +274,19 @@ namespace OpenSim.Region.ClientStack
276 throw (ex); 274 throw (ex);
277 275
278 // We are looking for alternate ports! 276 // We are looking for alternate ports!
279 m_log.Verbose("SERVER", "UDP socket on " + listenIP.ToString() + " " + listenPort.ToString() + " is not available, trying next."); 277 m_log.Info("[SERVER]: UDP socket on " + listenIP.ToString() + " " + listenPort.ToString() + " is not available, trying next.");
280 } 278 }
281 System.Threading.Thread.Sleep(100); // Wait before we retry socket 279 System.Threading.Thread.Sleep(100); // Wait before we retry socket
282 } 280 }
283 281
284 m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); 282 m_log.Info("[SERVER]: UDP socket bound, getting ready to listen");
285 283
286 ipeSender = new IPEndPoint(listenIP, 0); 284 ipeSender = new IPEndPoint(listenIP, 0);
287 epSender = (EndPoint) ipeSender; 285 epSender = (EndPoint) ipeSender;
288 ReceivedData = new AsyncCallback(OnReceivedData); 286 ReceivedData = new AsyncCallback(OnReceivedData);
289 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 287 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
290 288
291 m_log.Status("SERVER", "Listening on port " + newPort); 289 m_log.Info("[SERVER]: Listening on port " + newPort);
292 } 290 }
293 291
294 public virtual void RegisterPacketServer(PacketServer server) 292 public virtual void RegisterPacketServer(PacketServer server)