diff options
author | UbitUmarov | 2014-10-18 18:27:38 +0100 |
---|---|---|
committer | UbitUmarov | 2014-10-18 18:27:38 +0100 |
commit | b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a (patch) | |
tree | f3aad5ddf863954a27407695d3bac7e9e2dceb23 /OpenSim/Region/CoreModules | |
parent | debug makeroot timing (diff) | |
download | opensim-SC-b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a.zip opensim-SC-b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a.tar.gz opensim-SC-b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a.tar.bz2 opensim-SC-b7708b9d1f9cee1c10283d3178eabc2ce0c8a81a.tar.xz |
change child agents creation/notification. As before this assumes that
sending regions close out of view connections.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 234 |
1 files changed, 116 insertions, 118 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 56229df..24d1270 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1875,9 +1875,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1875 | //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); | 1875 | //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); |
1876 | 1876 | ||
1877 | sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); | 1877 | sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); |
1878 | //foreach (ulong h in agent.ChildrenCapSeeds.Keys) | ||
1879 | // m_log.DebugFormat("[XXX] --> {0}", h); | ||
1880 | //m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle); | ||
1881 | agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); | 1878 | agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); |
1882 | 1879 | ||
1883 | if (sp.Scene.CapsModule != null) | 1880 | if (sp.Scene.CapsModule != null) |
@@ -1920,6 +1917,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1920 | /// <param name="sp"></param> | 1917 | /// <param name="sp"></param> |
1921 | public void EnableChildAgents(ScenePresence sp) | 1918 | public void EnableChildAgents(ScenePresence sp) |
1922 | { | 1919 | { |
1920 | // assumes that out of view range regions are disconnected by the previus region | ||
1921 | |||
1923 | List<GridRegion> neighbours = new List<GridRegion>(); | 1922 | List<GridRegion> neighbours = new List<GridRegion>(); |
1924 | RegionInfo m_regionInfo = sp.Scene.RegionInfo; | 1923 | RegionInfo m_regionInfo = sp.Scene.RegionInfo; |
1925 | 1924 | ||
@@ -1952,8 +1951,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1952 | 1951 | ||
1953 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 1952 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1954 | 1953 | ||
1955 | List<ulong> newneighbours = new List<ulong>(); | ||
1956 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | 1954 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); |
1955 | List<GridRegion> newneighbours = new List<GridRegion>(); | ||
1957 | 1956 | ||
1958 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; | 1957 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; |
1959 | 1958 | ||
@@ -1961,9 +1960,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1961 | { | 1960 | { |
1962 | ulong handler = neighbour.RegionHandle; | 1961 | ulong handler = neighbour.RegionHandle; |
1963 | 1962 | ||
1963 | if (previousRegionNeighbourHandles.Contains(handler)) | ||
1964 | { | ||
1965 | // agent already knows this region | ||
1966 | previousRegionNeighbourHandles.Remove(handler); | ||
1967 | continue; | ||
1968 | } | ||
1969 | |||
1964 | if (handler == currentRegionHandler) | 1970 | if (handler == currentRegionHandler) |
1965 | continue; | 1971 | continue; |
1966 | 1972 | ||
1973 | // a new region to add | ||
1967 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); | 1974 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); |
1968 | agent.BaseFolder = UUID.Zero; | 1975 | agent.BaseFolder = UUID.Zero; |
1969 | agent.InventoryFolder = UUID.Zero; | 1976 | agent.InventoryFolder = UUID.Zero; |
@@ -1982,86 +1989,71 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1982 | agent.Id0 = currentAgentCircuit.Id0; | 1989 | agent.Id0 = currentAgentCircuit.Id0; |
1983 | } | 1990 | } |
1984 | 1991 | ||
1985 | if (previousRegionNeighbourHandles.Contains(handler)) | 1992 | newneighbours.Add(neighbour); |
1986 | { | 1993 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); |
1987 | previousRegionNeighbourHandles.Remove(handler); | 1994 | seeds.Add(handler, agent.CapsPath); |
1988 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, handler); | ||
1989 | } | ||
1990 | else | ||
1991 | { | ||
1992 | newneighbours.Add(handler); | ||
1993 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
1994 | sp.AddNeighbourRegion(handler, agent.CapsPath); | ||
1995 | seeds.Add(handler, agent.CapsPath); | ||
1996 | } | ||
1997 | |||
1998 | cagents.Add(agent); | 1995 | cagents.Add(agent); |
1999 | } | 1996 | } |
2000 | 1997 | ||
2001 | //sp.DropOldNeighbours(previousRegionNeighbourHandles); | 1998 | if (previousRegionNeighbourHandles.Contains(currentRegionHandler)) |
2002 | foreach (ulong handle in previousRegionNeighbourHandles) | 1999 | previousRegionNeighbourHandles.Remove(currentRegionHandler); |
2003 | { | 2000 | |
2004 | sp.RemoveNeighbourRegion(handle); | 2001 | // previousRegionNeighbourHandles now contains regions to forget |
2005 | Scene.CapsModule.DropChildSeed(sp.UUID, handle); | 2002 | foreach (uint handler in previousRegionNeighbourHandles) |
2006 | } | 2003 | seeds.Remove(handler); |
2007 | 2004 | ||
2008 | /// Update all child agent with everyone's seeds | 2005 | /// Update all child agent with everyone's seeds |
2009 | foreach (AgentCircuitData a in cagents) | 2006 | foreach (AgentCircuitData a in cagents) |
2010 | { | ||
2011 | a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); | 2007 | a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); |
2012 | } | ||
2013 | 2008 | ||
2014 | if (sp.Scene.CapsModule != null) | 2009 | if (sp.Scene.CapsModule != null) |
2015 | { | ||
2016 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); | 2010 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); |
2017 | } | ||
2018 | 2011 | ||
2019 | sp.KnownRegions = seeds; | 2012 | sp.KnownRegions = seeds; |
2020 | //avatar.Scene.DumpChildrenSeeds(avatar.UUID); | 2013 | |
2021 | //avatar.DumpKnownRegions(); | 2014 | if (newneighbours.Count > 0) |
2022 | |||
2023 | Util.FireAndForget(delegate | ||
2024 | { | 2015 | { |
2025 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start | 2016 | Util.FireAndForget(delegate |
2026 | int count = 0; | ||
2027 | bool newagent; | ||
2028 | |||
2029 | foreach (GridRegion neighbour in neighbours) | ||
2030 | { | 2017 | { |
2031 | try | 2018 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start |
2032 | { | 2019 | int count = 0; |
2033 | newagent = newneighbours.Contains(neighbour.RegionHandle); | ||
2034 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newagent); | ||
2035 | } | ||
2036 | 2020 | ||
2037 | catch (ArgumentOutOfRangeException) | 2021 | foreach (GridRegion neighbour in newneighbours) |
2038 | { | ||
2039 | m_log.ErrorFormat( | ||
2040 | "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", | ||
2041 | neighbour.ExternalHostName, | ||
2042 | neighbour.RegionHandle, | ||
2043 | neighbour.RegionLocX, | ||
2044 | neighbour.RegionLocY); | ||
2045 | } | ||
2046 | catch (Exception e) | ||
2047 | { | 2022 | { |
2048 | m_log.ErrorFormat( | 2023 | try |
2049 | "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", | 2024 | { |
2050 | neighbour.ExternalHostName, | 2025 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, |
2051 | neighbour.RegionHandle, | 2026 | neighbour.ExternalEndPoint, true); |
2027 | count++; | ||
2028 | } | ||
2029 | catch (ArgumentOutOfRangeException) | ||
2030 | { | ||
2031 | m_log.ErrorFormat( | ||
2032 | "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", | ||
2033 | neighbour.ExternalHostName, | ||
2034 | neighbour.RegionHandle, | ||
2052 | neighbour.RegionLocX, | 2035 | neighbour.RegionLocX, |
2053 | neighbour.RegionLocY, | 2036 | neighbour.RegionLocY); |
2054 | e); | 2037 | } |
2055 | 2038 | catch (Exception e) | |
2056 | // FIXME: Okay, even though we've failed, we're still going to throw the exception on, | 2039 | { |
2057 | // since I don't know what will happen if we just let the client continue | 2040 | m_log.ErrorFormat( |
2058 | 2041 | "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", | |
2059 | // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. | 2042 | neighbour.ExternalHostName, |
2060 | // throw e; | 2043 | neighbour.RegionHandle, |
2044 | neighbour.RegionLocX, | ||
2045 | neighbour.RegionLocY, | ||
2046 | e); | ||
2047 | |||
2048 | // FIXME: Okay, even though we've failed, we're still going to throw the exception on, | ||
2049 | // since I don't know what will happen if we just let the client continue | ||
2050 | |||
2051 | // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. | ||
2052 | // throw e; | ||
2053 | } | ||
2061 | } | 2054 | } |
2062 | count++; | 2055 | }); |
2063 | } | 2056 | } |
2064 | }); | ||
2065 | } | 2057 | } |
2066 | 2058 | ||
2067 | Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) | 2059 | Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) |
@@ -2095,56 +2087,59 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2095 | private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, | 2087 | private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, |
2096 | IPEndPoint endPoint, bool newAgent) | 2088 | IPEndPoint endPoint, bool newAgent) |
2097 | { | 2089 | { |
2098 | Scene scene = sp.Scene; | ||
2099 | if (!newAgent) | ||
2100 | return; | ||
2101 | 2090 | ||
2102 | m_log.DebugFormat( | 2091 | if (newAgent) |
2103 | "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", | 2092 | { |
2104 | sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); | 2093 | Scene scene = sp.Scene; |
2105 | 2094 | ||
2106 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); | 2095 | m_log.DebugFormat( |
2096 | "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", | ||
2097 | sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); | ||
2107 | 2098 | ||
2108 | string reason = String.Empty; | 2099 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); |
2109 | 2100 | ||
2110 | bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); | 2101 | string reason = String.Empty; |
2111 | 2102 | ||
2112 | if (regionAccepted && newAgent) | 2103 | bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); |
2113 | { | ||
2114 | // give time for createAgent to finish, since it is async and does grid services access | ||
2115 | Thread.Sleep(500); | ||
2116 | 2104 | ||
2117 | if (m_eqModule != null) | 2105 | if (regionAccepted) |
2118 | { | 2106 | { |
2119 | #region IP Translation for NAT | 2107 | // give time for createAgent to finish, since it is async and does grid services access |
2120 | IClientIPEndpoint ipepClient; | 2108 | Thread.Sleep(500); |
2121 | if (sp.ClientView.TryGet(out ipepClient)) | 2109 | |
2110 | if (m_eqModule != null) | ||
2122 | { | 2111 | { |
2123 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | 2112 | #region IP Translation for NAT |
2124 | } | 2113 | IClientIPEndpoint ipepClient; |
2125 | #endregion | 2114 | if (sp.ClientView.TryGet(out ipepClient)) |
2115 | { | ||
2116 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
2117 | } | ||
2118 | #endregion | ||
2126 | 2119 | ||
2127 | m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + | 2120 | m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + |
2128 | "and EstablishAgentCommunication with seed cap {8}", LogHeader, | 2121 | "and EstablishAgentCommunication with seed cap {8}", LogHeader, |
2129 | scene.RegionInfo.RegionName, sp.Name, | 2122 | scene.RegionInfo.RegionName, sp.Name, |
2130 | reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY , capsPath); | 2123 | reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY, capsPath); |
2131 | 2124 | ||
2132 | m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); | 2125 | m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); |
2133 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); | 2126 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); |
2134 | } | 2127 | } |
2135 | else | 2128 | else |
2136 | { | 2129 | { |
2137 | sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); | 2130 | sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); |
2138 | // TODO: make Event Queue disablable! | 2131 | // TODO: make Event Queue disablable! |
2132 | } | ||
2133 | |||
2134 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); | ||
2139 | } | 2135 | } |
2140 | 2136 | ||
2141 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); | 2137 | if (!regionAccepted) |
2138 | m_log.WarnFormat( | ||
2139 | "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}", | ||
2140 | reg.RegionName, sp.Name, sp.UUID, reason); | ||
2142 | } | 2141 | } |
2143 | 2142 | ||
2144 | if (!regionAccepted) | ||
2145 | m_log.WarnFormat( | ||
2146 | "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}", | ||
2147 | reg.RegionName, sp.Name, sp.UUID, reason); | ||
2148 | } | 2143 | } |
2149 | 2144 | ||
2150 | /// <summary> | 2145 | /// <summary> |
@@ -2203,6 +2198,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2203 | int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | 2198 | int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); |
2204 | int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | 2199 | int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); |
2205 | 2200 | ||
2201 | if (startX < 0) startX = 0; | ||
2202 | if (startY < 0) startY = 0; | ||
2203 | |||
2206 | List<GridRegion> neighbours = | 2204 | List<GridRegion> neighbours = |
2207 | avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); | 2205 | avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); |
2208 | 2206 | ||
@@ -2227,7 +2225,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2227 | return neighbours; | 2225 | return neighbours; |
2228 | } | 2226 | } |
2229 | } | 2227 | } |
2230 | 2228 | /* not in use | |
2231 | private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) | 2229 | private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) |
2232 | { | 2230 | { |
2233 | return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); | 2231 | return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); |
@@ -2238,20 +2236,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2238 | // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); | 2236 | // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); |
2239 | // } | 2237 | // } |
2240 | 2238 | ||
2241 | private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) | 2239 | // private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) |
2242 | { | 2240 | // { |
2243 | return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); | 2241 | // return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); |
2244 | } | 2242 | // } |
2245 | 2243 | ||
2246 | private List<ulong> NeighbourHandles(List<GridRegion> neighbours) | 2244 | // private List<ulong> NeighbourHandles(List<GridRegion> neighbours) |
2247 | { | 2245 | // { |
2248 | List<ulong> handles = new List<ulong>(); | 2246 | // List<ulong> handles = new List<ulong>(); |
2249 | foreach (GridRegion reg in neighbours) | 2247 | // foreach (GridRegion reg in neighbours) |
2250 | { | 2248 | // { |
2251 | handles.Add(reg.RegionHandle); | 2249 | // handles.Add(reg.RegionHandle); |
2252 | } | 2250 | // } |
2253 | return handles; | 2251 | // return handles; |
2254 | } | 2252 | // } |
2255 | 2253 | ||
2256 | // private void Dump(string msg, List<ulong> handles) | 2254 | // private void Dump(string msg, List<ulong> handles) |
2257 | // { | 2255 | // { |
@@ -2265,7 +2263,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2265 | // m_log.InfoFormat("({0}, {1})", x, y); | 2263 | // m_log.InfoFormat("({0}, {1})", x, y); |
2266 | // } | 2264 | // } |
2267 | // } | 2265 | // } |
2268 | 2266 | */ | |
2269 | #endregion | 2267 | #endregion |
2270 | 2268 | ||
2271 | #region Agent Arrived | 2269 | #region Agent Arrived |