Improved fault handling in HelloNeighbour.

prioritization
Diva Canto 2009-10-07 08:42:33 -07:00
parent d344ca932d
commit 78e4501bef
1 changed files with 23 additions and 13 deletions

View File

@ -76,10 +76,12 @@ namespace OpenSim.Services.Connectors
// Don't remote-call this instance; that's a startup hickup // Don't remote-call this instance; that's a startup hickup
!((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
{ {
DoHelloNeighbourCall(regInfo, thisRegion); if (!DoHelloNeighbourCall(regInfo, thisRegion))
return null;
} }
//else else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle); return null;
return regInfo; return regInfo;
} }
@ -102,6 +104,7 @@ namespace OpenSim.Services.Connectors
catch (Exception e) catch (Exception e)
{ {
m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message);
return false;
} }
// Add the regionhandle of the destination region // Add the regionhandle of the destination region
args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString()); args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString());
@ -118,7 +121,7 @@ namespace OpenSim.Services.Connectors
catch (Exception e) catch (Exception e)
{ {
m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message);
// ignore. buffer will be empty, caller should check. return false;
} }
Stream os = null; Stream os = null;
@ -127,20 +130,23 @@ namespace OpenSim.Services.Connectors
HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send
os = HelloNeighbourRequest.GetRequestStream(); os = HelloNeighbourRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
//m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
} }
//catch (WebException ex) catch (Exception ex)
catch
{ {
//m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); m_log.InfoFormat("[REST COMMS]: Unable to send HelloNeighbour to {0}: {1}", region.RegionName, ex.Message);
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
StreamReader sr = null;
try try
{ {
WebResponse webResponse = HelloNeighbourRequest.GetResponse(); WebResponse webResponse = HelloNeighbourRequest.GetResponse();
@ -149,17 +155,21 @@ namespace OpenSim.Services.Connectors
m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post");
} }
StreamReader sr = new StreamReader(webResponse.GetResponseStream()); sr = new StreamReader(webResponse.GetResponseStream());
//reply = sr.ReadToEnd().Trim(); //reply = sr.ReadToEnd().Trim();
sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim();
sr.Close();
//m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
} }
catch (WebException ex) catch (Exception ex)
{ {
m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message);
// ignore, really return false;
}
finally
{
if (sr != null)
sr.Close();
} }
return true; return true;