diff options
author | UbitUmarov | 2016-07-09 01:32:27 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-09 01:32:27 +0100 |
commit | 415c45b0971dbd7b16587ce9f02cb68cf740a13d (patch) | |
tree | 4841da6c1b0945042b4f7e2529a276da1f2e6ff8 /OpenSim/Region/CoreModules/Agent | |
parent | some changes to RequestInventoryFile() (diff) | |
download | opensim-SC_OLD-415c45b0971dbd7b16587ce9f02cb68cf740a13d.zip opensim-SC_OLD-415c45b0971dbd7b16587ce9f02cb68cf740a13d.tar.gz opensim-SC_OLD-415c45b0971dbd7b16587ce9f02cb68cf740a13d.tar.bz2 opensim-SC_OLD-415c45b0971dbd7b16587ce9f02cb68cf740a13d.tar.xz |
add a simple files expire to Xfer to catch some that never got a request (opened xfers also need a timeout) (not pretty code, but should not have heavy use)
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index 7113f4f..391326f 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
45 | private Scene m_scene; | 45 | private Scene m_scene; |
46 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); | 46 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); |
47 | private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | 47 | private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); |
48 | 48 | private double lastFilesExpire = 0; | |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | public struct XferRequest | 51 | public struct XferRequest |
@@ -59,13 +59,15 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
59 | private class FileData | 59 | private class FileData |
60 | { | 60 | { |
61 | public byte[] Data; | 61 | public byte[] Data; |
62 | public int Count; | 62 | public int refsCount; |
63 | public double timeStampMS; | ||
63 | } | 64 | } |
64 | 65 | ||
65 | #region INonSharedRegionModule Members | 66 | #region INonSharedRegionModule Members |
66 | 67 | ||
67 | public void Initialise(IConfigSource config) | 68 | public void Initialise(IConfigSource config) |
68 | { | 69 | { |
70 | lastFilesExpire = Util.GetTimeStampMS() + 300000.0; | ||
69 | } | 71 | } |
70 | 72 | ||
71 | public void AddRegion(Scene scene) | 73 | public void AddRegion(Scene scene) |
@@ -118,20 +120,36 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
118 | { | 120 | { |
119 | lock (NewFiles) | 121 | lock (NewFiles) |
120 | { | 122 | { |
123 | double now = Util.GetTimeStampMS(); | ||
121 | if (NewFiles.ContainsKey(fileName)) | 124 | if (NewFiles.ContainsKey(fileName)) |
122 | { | 125 | { |
123 | NewFiles[fileName].Count++; | 126 | NewFiles[fileName].refsCount++; |
124 | NewFiles[fileName].Data = data; | 127 | NewFiles[fileName].Data = data; |
128 | NewFiles[fileName].timeStampMS = now; | ||
125 | } | 129 | } |
126 | else | 130 | else |
127 | { | 131 | { |
128 | FileData fd = new FileData(); | 132 | FileData fd = new FileData(); |
129 | fd.Count = 1; | 133 | fd.refsCount = 1; |
130 | fd.Data = data; | 134 | fd.Data = data; |
135 | fd.timeStampMS = now; | ||
131 | NewFiles.Add(fileName, fd); | 136 | NewFiles.Add(fileName, fd); |
132 | } | 137 | } |
133 | } | ||
134 | 138 | ||
139 | // lazy expires hopefully we will not have many files so nasty code will do it | ||
140 | if(now - lastFilesExpire > 180000.0) | ||
141 | { | ||
142 | lastFilesExpire = now; | ||
143 | List<string> expires = new List<string>(); | ||
144 | foreach(string fname in NewFiles.Keys) | ||
145 | { | ||
146 | if(NewFiles[fname].refsCount == 0 && now - NewFiles[fname].timeStampMS > 180000.0) | ||
147 | expires.Add(fname); | ||
148 | } | ||
149 | foreach(string fname in expires) | ||
150 | NewFiles.Remove(fname); | ||
151 | } | ||
152 | } | ||
135 | return true; | 153 | return true; |
136 | } | 154 | } |
137 | 155 | ||
@@ -226,10 +244,10 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
226 | 244 | ||
227 | if (NewFiles.ContainsKey(fileName)) | 245 | if (NewFiles.ContainsKey(fileName)) |
228 | { | 246 | { |
229 | if (NewFiles[fileName].Count == 1) | 247 | if (NewFiles[fileName].refsCount == 1) |
230 | NewFiles.Remove(fileName); | 248 | NewFiles.Remove(fileName); |
231 | else | 249 | else |
232 | NewFiles[fileName].Count--; | 250 | NewFiles[fileName].refsCount--; |
233 | } | 251 | } |
234 | } | 252 | } |
235 | 253 | ||