Stop IGridService from throwing a fatal exception when an IPEndPoint cannot be resolved, and add some handlers to deal with this cleanly; a condition was observed on OSGrid where a neighbouring region with an invalid (unresolveable) hostname would prevent a region from starting. This is bad.

avinationmerge
Tom Grimshaw 2010-05-29 01:03:59 -07:00
parent ea5bcc7b88
commit 2f409116db
8 changed files with 53 additions and 19 deletions

View File

@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work. // it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint; IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint.Address != null) if (endPoint != null && endPoint.Address != null)
{ {
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions // both regions
@ -825,15 +825,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
if (eq != null) IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint;
if (neighbourExternal != null)
{ {
eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, if (eq != null)
capsPath, agent.UUID, agent.ControllingClient.SessionId); {
} eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
else capsPath, agent.UUID, agent.ControllingClient.SessionId);
{ }
agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, else
capsPath); {
agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
capsPath);
}
} }
if (!WaitForCallback(agent.UUID)) if (!WaitForCallback(agent.UUID))
@ -906,10 +910,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.child = true; agent.child = true;
agent.Appearance = sp.Appearance; agent.Appearance = sp.Appearance;
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; IPEndPoint external = region.ExternalEndPoint;
d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, if (external != null)
{
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
d.BeginInvoke(sp, agent, region, external, true,
InformClientOfNeighbourCompleted, InformClientOfNeighbourCompleted,
d); d);
}
} }
#endregion #endregion
@ -1038,6 +1046,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
try try
{ {
//neighbour.ExternalEndPoint may return null, which will be caught
d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
InformClientOfNeighbourCompleted, InformClientOfNeighbourCompleted,
d); d);

View File

@ -87,7 +87,12 @@ namespace OpenSim.Services.Connectors.Hypergrid
paramList.Add(hash); paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; IPEndPoint ext = info.ExternalEndPoint;
string uri = "";
if (ext != null)
{
uri = "http://" + ext.Address + ":" + info.HttpPort + "/";
}
//m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri); //m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri);
XmlRpcResponse response = null; XmlRpcResponse response = null;
try try
@ -189,7 +194,12 @@ namespace OpenSim.Services.Connectors.Hypergrid
paramList.Add(hash); paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); XmlRpcRequest request = new XmlRpcRequest("get_region", paramList);
string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; IPEndPoint ext = gatekeeper.ExternalEndPoint;
string uri = "";
if (ext != null)
{
uri = "http://" + ext.Address + ":" + gatekeeper.HttpPort + "/";
}
m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri);
XmlRpcResponse response = null; XmlRpcResponse response = null;
try try

View File

@ -83,6 +83,8 @@ namespace OpenSim.Services.Connectors
if (info != null) // just to be sure if (info != null) // just to be sure
{ {
XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
//Possible nullref from info.externalendpoint will be caught here
string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
XmlRpcResponse response = request.Send(uri, 10000); XmlRpcResponse response = request.Send(uri, 10000);
if (response.IsFault) if (response.IsFault)

View File

@ -87,7 +87,9 @@ namespace OpenSim.Services.Connectors
public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
{ {
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; IPEndPoint ext = region.ExternalEndPoint;
if (ext == null) return false;
string uri = "http://" + ext.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
//m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri);
WebRequest HelloNeighbourRequest = WebRequest.Create(uri); WebRequest HelloNeighbourRequest = WebRequest.Create(uri);

View File

@ -104,6 +104,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
public string RegisterRegion(UUID scopeID, GridRegion regionInfo) public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
IPEndPoint ext = regionInfo.ExternalEndPoint;
if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0);
@ -114,7 +116,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ServerURI", OSD.FromString(regionInfo.ServerURI) }, { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
{ "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
{ "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
{ "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
{ "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
{ "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
{ "Access", OSD.FromInteger(regionInfo.Access) }, { "Access", OSD.FromInteger(regionInfo.Access) },

View File

@ -348,9 +348,11 @@ namespace OpenSim.Services.Connectors.Simulation
public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
{ {
IPEndPoint ext = destination.ExternalEndPoint;
agent = null; agent = null;
if (ext == null) return false;
// Eventually, we want to use a caps url instead of the agentID // Eventually, we want to use a caps url instead of the agentID
string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; string uri = "http://" + ext.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
//Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
@ -514,8 +516,10 @@ namespace OpenSim.Services.Connectors.Simulation
public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
{ {
IPEndPoint ext = destination.ExternalEndPoint;
if (ext == null) return false;
string uri string uri
= "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/"; = "http://" + ext.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/";
//m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri);
WebRequest ObjectCreateRequest = WebRequest.Create(uri); WebRequest ObjectCreateRequest = WebRequest.Create(uri);

View File

@ -259,9 +259,13 @@ namespace OpenSim.Services.Interfaces
} }
catch (SocketException e) catch (SocketException e)
{ {
throw new Exception( /*throw new Exception(
"Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
e + "' attached to this exception", e); e + "' attached to this exception", e);*/
// Don't throw a fatal exception here, instead, return Null and handle it in the caller.
// Reason is, on systems such as OSgrid it has occured that known hostnames stop
// resolving and thus make surrounding regions crash out with this exception.
return null;
} }
return new IPEndPoint(ia, m_internalEndPoint.Port); return new IPEndPoint(ia, m_internalEndPoint.Port);

View File

@ -327,6 +327,7 @@ namespace OpenSim.Services.LLLoginService
private void FillOutRegionData(GridRegion destination) private void FillOutRegionData(GridRegion destination)
{ {
IPEndPoint endPoint = destination.ExternalEndPoint; IPEndPoint endPoint = destination.ExternalEndPoint;
if (endPoint == null) return;
SimAddress = endPoint.Address.ToString(); SimAddress = endPoint.Address.ToString();
SimPort = (uint)endPoint.Port; SimPort = (uint)endPoint.Port;
RegionX = (uint)destination.RegionLocX; RegionX = (uint)destination.RegionLocX;