From dd491bba57bcf5042fd5f1bbad28fe5cde8a461b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 18 Jan 2018 04:28:05 +0000 Subject: [PATCH] abort uploading large region map tiles as soon one fails --- .../MapImage/MapImageServiceModule.cs | 34 +++++++++++-------- .../MapImage/MapImageServicesConnector.cs | 3 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 9888c3b189..666e5578d7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -244,11 +244,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage (int)Constants.RegionSize, (int)Constants.RegionSize); using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) { - ConvertAndUploadMaptile(scene, subMapTile, + if(!ConvertAndUploadMaptile(scene, subMapTile, scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), - scene.Name); - } + scene.Name)); + { + m_log.DebugFormat("{0} Upload maptileS for {1} aborted!", LogHeader, scene.Name); + return; // abort rest; + } + } } } } @@ -280,7 +284,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } } - private void ConvertAndUploadMaptile(IScene scene, Image tileImage, uint locX, uint locY, string regionName) + private bool ConvertAndUploadMaptile(IScene scene, Image tileImage, uint locX, uint locY, string regionName) { byte[] jpgData = Utils.EmptyBytes; @@ -289,19 +293,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage tileImage.Save(stream, ImageFormat.Jpeg); jpgData = stream.ToArray(); } - if (jpgData != Utils.EmptyBytes) - { - string reason = string.Empty; - if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) - { - m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, - regionName, locX, locY, reason); - } - } - else + + if (jpgData == Utils.EmptyBytes) { m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName); + return false; } + + string reason = string.Empty; + if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) + { + m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, + regionName, locX, locY, reason); + return false; + } + return true; } } } diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index 84c4efe378..762d2f7c30 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -229,6 +229,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, + 30, m_Auth); if (reply != string.Empty) { @@ -271,7 +272,7 @@ namespace OpenSim.Services.Connectors { // This just dumps a warning for any operation that takes more than 100 ms int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff); + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile upload time {0}ms", tickdiff); } return false;