diff options
author | Tedd Hansen | 2008-02-02 06:34:07 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-02 06:34:07 +0000 |
commit | b089ccfa3d351b4dba43bcbc284d87d7c4963dae (patch) | |
tree | 19c7e9baea656b1c112754ce777cde391101369b /OpenSim | |
parent | Last patch was a disaster... reset terrain whenever bug occurred. Trying agai... (diff) | |
download | opensim-SC-b089ccfa3d351b4dba43bcbc284d87d7c4963dae.zip opensim-SC-b089ccfa3d351b4dba43bcbc284d87d7c4963dae.tar.gz opensim-SC-b089ccfa3d351b4dba43bcbc284d87d7c4963dae.tar.bz2 opensim-SC-b089ccfa3d351b4dba43bcbc284d87d7c4963dae.tar.xz |
Hopefully fixed MySQL DB crash on startup issue (so we can remove 3 sec wait).
Added option to try alternate UDP ports if the one configured is in use.
UDP packets are now bound to the actual outside IP address and hopefully won't "randomly" select IP on multihomed systems.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Console/LogBase.cs | 14 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 5 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 16 | ||||
-rw-r--r-- | OpenSim/Framework/SerializableRegionInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/RegionApplicationBase.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/UDPServer.cs | 45 |
6 files changed, 78 insertions, 14 deletions
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index 0036921..f7d0d1f 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs | |||
@@ -67,7 +67,19 @@ namespace OpenSim.Framework.Console | |||
67 | 67 | ||
68 | System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); | 68 | System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); |
69 | 69 | ||
70 | Log = File.AppendText(LogFile); | 70 | try |
71 | { | ||
72 | Log = File.AppendText(LogFile); | ||
73 | } | ||
74 | catch (Exception ex) | ||
75 | { | ||
76 | System.Console.WriteLine("Unable to open log file. Do you already have another copy of OpenSim running? Permission problem?"); | ||
77 | System.Console.WriteLine(ex.Message); | ||
78 | System.Console.WriteLine(""); | ||
79 | System.Console.WriteLine("Application is terminating."); | ||
80 | System.Console.WriteLine(""); | ||
81 | System.Threading.Thread.CurrentThread.Abort(); | ||
82 | } | ||
71 | Log.WriteLine("========================================================================"); | 83 | Log.WriteLine("========================================================================"); |
72 | Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString()); | 84 | Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString()); |
73 | } | 85 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index 7ac4bde..45d0720 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | |||
@@ -417,8 +417,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
417 | 417 | ||
418 | public void StoreLandObject(Land parcel, LLUUID regionUUID) | 418 | public void StoreLandObject(Land parcel, LLUUID regionUUID) |
419 | { | 419 | { |
420 | MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); | 420 | // Does the new locking fix it? |
421 | System.Threading.Thread.Sleep(3000); | 421 | //MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); |
422 | //System.Threading.Thread.Sleep(3000); | ||
422 | 423 | ||
423 | lock (DBAccessLock) | 424 | lock (DBAccessLock) |
424 | { | 425 | { |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 8d4e905..b843774 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -67,6 +67,7 @@ namespace OpenSim.Framework | |||
67 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 67 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
68 | m_externalHostName = ConvertFrom.ExternalHostName; | 68 | m_externalHostName = ConvertFrom.ExternalHostName; |
69 | m_remotingPort = ConvertFrom.RemotingPort; | 69 | m_remotingPort = ConvertFrom.RemotingPort; |
70 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
70 | RemotingAddress = ConvertFrom.RemotingAddress; | 71 | RemotingAddress = ConvertFrom.RemotingAddress; |
71 | RegionID = LLUUID.Zero; | 72 | RegionID = LLUUID.Zero; |
72 | } | 73 | } |
@@ -80,6 +81,7 @@ namespace OpenSim.Framework | |||
80 | get { return m_remotingPort; } | 81 | get { return m_remotingPort; } |
81 | set { m_remotingPort = value; } | 82 | set { m_remotingPort = value; } |
82 | } | 83 | } |
84 | public bool m_allow_alternate_ports; | ||
83 | 85 | ||
84 | public string RemotingAddress; | 86 | public string RemotingAddress; |
85 | 87 | ||
@@ -125,6 +127,8 @@ namespace OpenSim.Framework | |||
125 | set { m_externalHostName = value; } | 127 | set { m_externalHostName = value; } |
126 | } | 128 | } |
127 | 129 | ||
130 | protected bool Allow_Alternate_Ports; | ||
131 | |||
128 | protected IPEndPoint m_internalEndPoint; | 132 | protected IPEndPoint m_internalEndPoint; |
129 | 133 | ||
130 | public IPEndPoint InternalEndPoint | 134 | public IPEndPoint InternalEndPoint |
@@ -163,6 +167,8 @@ namespace OpenSim.Framework | |||
163 | public bool isSandbox = false; | 167 | public bool isSandbox = false; |
164 | public bool commFailTF = false; | 168 | public bool commFailTF = false; |
165 | 169 | ||
170 | public bool m_allow_alternate_ports; | ||
171 | |||
166 | public LLUUID MasterAvatarAssignedUUID = LLUUID.Zero; | 172 | public LLUUID MasterAvatarAssignedUUID = LLUUID.Zero; |
167 | public LLUUID CovenantID = LLUUID.Zero; | 173 | public LLUUID CovenantID = LLUUID.Zero; |
168 | public string MasterAvatarFirstName = String.Empty; | 174 | public string MasterAvatarFirstName = String.Empty; |
@@ -217,6 +223,7 @@ namespace OpenSim.Framework | |||
217 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 223 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
218 | m_externalHostName = ConvertFrom.ExternalHostName; | 224 | m_externalHostName = ConvertFrom.ExternalHostName; |
219 | m_remotingPort = ConvertFrom.RemotingPort; | 225 | m_remotingPort = ConvertFrom.RemotingPort; |
226 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
220 | RemotingAddress = ConvertFrom.RemotingAddress; | 227 | RemotingAddress = ConvertFrom.RemotingAddress; |
221 | RegionID = LLUUID.Zero; | 228 | RegionID = LLUUID.Zero; |
222 | } | 229 | } |
@@ -228,6 +235,7 @@ namespace OpenSim.Framework | |||
228 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 235 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
229 | m_externalHostName = ConvertFrom.ExternalHostName; | 236 | m_externalHostName = ConvertFrom.ExternalHostName; |
230 | m_remotingPort = ConvertFrom.RemotingPort; | 237 | m_remotingPort = ConvertFrom.RemotingPort; |
238 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
231 | RemotingAddress = ConvertFrom.RemotingAddress; | 239 | RemotingAddress = ConvertFrom.RemotingAddress; |
232 | RegionID = LLUUID.Zero; | 240 | RegionID = LLUUID.Zero; |
233 | } | 241 | } |
@@ -300,6 +308,9 @@ namespace OpenSim.Framework | |||
300 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 308 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
301 | "Internal IP Port for incoming UDP client connections", | 309 | "Internal IP Port for incoming UDP client connections", |
302 | NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); | 310 | NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); |
311 | configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
312 | "Allow sim to find alternate UDP ports when ports are in use?", | ||
313 | "false", false); | ||
303 | configMember.addConfigurationOption("external_host_name", | 314 | configMember.addConfigurationOption("external_host_name", |
304 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 315 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
305 | "External Host Name", "127.0.0.1", false); | 316 | "External Host Name", "127.0.0.1", false); |
@@ -357,7 +368,10 @@ namespace OpenSim.Framework | |||
357 | m_internalEndPoint = new IPEndPoint(address, 0); | 368 | m_internalEndPoint = new IPEndPoint(address, 0); |
358 | break; | 369 | break; |
359 | case "internal_ip_port": | 370 | case "internal_ip_port": |
360 | m_internalEndPoint.Port = (int) configuration_result; | 371 | m_internalEndPoint.Port = (int)configuration_result; |
372 | break; | ||
373 | case "allow_alternate_ports": | ||
374 | m_allow_alternate_ports = (bool)configuration_result; | ||
361 | break; | 375 | break; |
362 | case "external_host_name": | 376 | case "external_host_name": |
363 | if ((string) configuration_result != "SYSTEMIP") | 377 | if ((string) configuration_result != "SYSTEMIP") |
diff --git a/OpenSim/Framework/SerializableRegionInfo.cs b/OpenSim/Framework/SerializableRegionInfo.cs index 18a3829..0097fe4 100644 --- a/OpenSim/Framework/SerializableRegionInfo.cs +++ b/OpenSim/Framework/SerializableRegionInfo.cs | |||
@@ -49,6 +49,7 @@ namespace OpenSim.Framework | |||
49 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 49 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
50 | m_externalHostName = ConvertFrom.ExternalHostName; | 50 | m_externalHostName = ConvertFrom.ExternalHostName; |
51 | m_remotingPort = ConvertFrom.RemotingPort; | 51 | m_remotingPort = ConvertFrom.RemotingPort; |
52 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
52 | RemotingAddress = ConvertFrom.RemotingAddress; | 53 | RemotingAddress = ConvertFrom.RemotingAddress; |
53 | } | 54 | } |
54 | 55 | ||
@@ -80,6 +81,7 @@ namespace OpenSim.Framework | |||
80 | get { return m_remotingPort; } | 81 | get { return m_remotingPort; } |
81 | set { m_remotingPort = value; } | 82 | set { m_remotingPort = value; } |
82 | } | 83 | } |
84 | public bool m_allow_alternate_ports; | ||
83 | 85 | ||
84 | public string RemotingAddress; | 86 | public string RemotingAddress; |
85 | 87 | ||
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index e74873d..f8b0c9e 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -109,10 +109,16 @@ namespace OpenSim.Region.ClientStack | |||
109 | protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer, bool m_permissions) | 109 | protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer, bool m_permissions) |
110 | { | 110 | { |
111 | AgentCircuitManager circuitManager = new AgentCircuitManager(); | 111 | AgentCircuitManager circuitManager = new AgentCircuitManager(); |
112 | udpServer = new UDPServer((uint) regionInfo.InternalEndPoint.Port, m_assetCache, m_log, circuitManager); | 112 | IPAddress listenIP; |
113 | if (!IPAddress.TryParse(regionInfo.ExternalHostName, out listenIP)) | ||
114 | listenIP = IPAddress.Parse("0.0.0.0"); | ||
113 | 115 | ||
114 | Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager); | 116 | uint port = (uint) regionInfo.InternalEndPoint.Port; |
117 | udpServer = new UDPServer(listenIP, ref port, regionInfo.m_allow_alternate_ports, m_assetCache, m_log, circuitManager); | ||
118 | regionInfo.InternalEndPoint.Port = (int)port; | ||
115 | 119 | ||
120 | Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager); | ||
121 | |||
116 | udpServer.LocalScene = scene; | 122 | udpServer.LocalScene = scene; |
117 | 123 | ||
118 | scene.LoadWorldMap(); | 124 | scene.LoadWorldMap(); |
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index dc76c20..e292c2c 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs | |||
@@ -52,6 +52,8 @@ namespace OpenSim.Region.ClientStack | |||
52 | protected ulong m_regionHandle; | 52 | protected ulong m_regionHandle; |
53 | 53 | ||
54 | protected uint listenPort; | 54 | protected uint listenPort; |
55 | protected bool Allow_Alternate_Port; | ||
56 | protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); | ||
55 | protected IScene m_localScene; | 57 | protected IScene m_localScene; |
56 | protected AssetCache m_assetCache; | 58 | protected AssetCache m_assetCache; |
57 | protected LogBase m_log; | 59 | protected LogBase m_log; |
@@ -82,13 +84,20 @@ namespace OpenSim.Region.ClientStack | |||
82 | { | 84 | { |
83 | } | 85 | } |
84 | 86 | ||
85 | public UDPServer(uint port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) | 87 | public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) |
86 | { | 88 | { |
89 | listenIP = _listenIP; | ||
87 | listenPort = port; | 90 | listenPort = port; |
91 | Allow_Alternate_Port = allow_alternate_port; | ||
88 | m_assetCache = assetCache; | 92 | m_assetCache = assetCache; |
89 | m_log = console; | 93 | m_log = console; |
90 | m_authenticateSessionsClass = authenticateClass; | 94 | m_authenticateSessionsClass = authenticateClass; |
91 | CreatePacketServer(); | 95 | CreatePacketServer(); |
96 | |||
97 | // Return new port | ||
98 | // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. | ||
99 | // So the option allow_alternate_ports="true" was added to default.xml | ||
100 | port = listenPort; | ||
92 | } | 101 | } |
93 | 102 | ||
94 | protected virtual void CreatePacketServer() | 103 | protected virtual void CreatePacketServer() |
@@ -98,7 +107,7 @@ namespace OpenSim.Region.ClientStack | |||
98 | 107 | ||
99 | protected virtual void OnReceivedData(IAsyncResult result) | 108 | protected virtual void OnReceivedData(IAsyncResult result) |
100 | { | 109 | { |
101 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 110 | ipeSender = new IPEndPoint(listenIP, 0); |
102 | epSender = (EndPoint) ipeSender; | 111 | epSender = (EndPoint) ipeSender; |
103 | Packet packet = null; | 112 | Packet packet = null; |
104 | 113 | ||
@@ -246,20 +255,40 @@ namespace OpenSim.Region.ClientStack | |||
246 | 255 | ||
247 | public void ServerListener() | 256 | public void ServerListener() |
248 | { | 257 | { |
249 | m_log.Verbose("SERVER", "Opening UDP socket on " + listenPort.ToString()); | ||
250 | 258 | ||
251 | ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) listenPort); | 259 | uint newPort = listenPort; |
252 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | 260 | for (uint i = 0; i < 10; i++) |
253 | Server.Bind(ServerIncoming); | 261 | { |
262 | newPort = listenPort + i; | ||
263 | m_log.Verbose("SERVER", "Opening UDP socket on " + listenIP.ToString() + " " + newPort + ". Allow alternate ports: " + Allow_Alternate_Port.ToString()); | ||
264 | try | ||
265 | { | ||
266 | ServerIncoming = new IPEndPoint(listenIP, (int) newPort); | ||
267 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
268 | Server.Bind(ServerIncoming); | ||
269 | listenPort = newPort; | ||
270 | break; | ||
271 | } | ||
272 | catch (Exception ex) | ||
273 | { | ||
274 | // We are not looking for alternate ports? | ||
275 | if (!Allow_Alternate_Port) | ||
276 | throw (ex); | ||
277 | |||
278 | // We are looking for alternate ports! | ||
279 | m_log.Verbose("SERVER", "UDP socket on " + listenIP.ToString() + " " + listenPort.ToString() + " is not available, trying next."); | ||
280 | } | ||
281 | System.Threading.Thread.Sleep(100); // Wait before we retry socket | ||
282 | } | ||
254 | 283 | ||
255 | m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); | 284 | m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); |
256 | 285 | ||
257 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 286 | ipeSender = new IPEndPoint(listenIP, 0); |
258 | epSender = (EndPoint) ipeSender; | 287 | epSender = (EndPoint) ipeSender; |
259 | ReceivedData = new AsyncCallback(OnReceivedData); | 288 | ReceivedData = new AsyncCallback(OnReceivedData); |
260 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 289 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
261 | 290 | ||
262 | m_log.Status("SERVER", "Listening..."); | 291 | m_log.Status("SERVER", "Listening on port " + newPort); |
263 | } | 292 | } |
264 | 293 | ||
265 | public virtual void RegisterPacketServer(PacketServer server) | 294 | public virtual void RegisterPacketServer(PacketServer server) |