diff options
author | Diva Canto | 2010-12-24 08:50:00 -0800 |
---|---|---|
committer | Diva Canto | 2010-12-24 08:50:00 -0800 |
commit | 3eaaaa0d994c7c994d471d511127ed0ba66ab9bc (patch) | |
tree | 94f784b0cc76ebe3c527657a8af3b5621bf212fd /OpenSim/Region/CoreModules/Agent | |
parent | Hopefully this fixes all prim inventory issues. No more abort, no more keepin... (diff) | |
download | opensim-SC_OLD-3eaaaa0d994c7c994d471d511127ed0ba66ab9bc.zip opensim-SC_OLD-3eaaaa0d994c7c994d471d511127ed0ba66ab9bc.tar.gz opensim-SC_OLD-3eaaaa0d994c7c994d471d511127ed0ba66ab9bc.tar.bz2 opensim-SC_OLD-3eaaaa0d994c7c994d471d511127ed0ba66ab9bc.tar.xz |
One more pass at object inventory. This time, fix SceneObjectPartInventory so that it makes sure that the file is added to Xfer's before it signals the client to come and get it. This allows the simplification of the logic of Xfer's.
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | 94 |
1 files changed, 14 insertions, 80 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index df4ff05..b8e2820 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -27,7 +27,9 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
30 | using Nini.Config; | 31 | using Nini.Config; |
32 | using log4net; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
@@ -37,12 +39,11 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
37 | { | 39 | { |
38 | public class XferModule : IRegionModule, IXfer | 40 | public class XferModule : IRegionModule, IXfer |
39 | { | 41 | { |
40 | private static uint counter = 0; | ||
41 | private Scene m_scene; | 42 | private Scene m_scene; |
42 | private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>(); | ||
43 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); | 43 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); |
44 | private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | 44 | private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); |
45 | 45 | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | 47 | ||
47 | public struct XferRequest | 48 | public struct XferRequest |
48 | { | 49 | { |
@@ -90,6 +91,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
90 | 91 | ||
91 | #region IXfer Members | 92 | #region IXfer Members |
92 | 93 | ||
94 | /// <summary> | ||
95 | /// Let the Xfer module know about a file that the client is about to request. | ||
96 | /// Caller is responsible for making sure that the file is here before | ||
97 | /// the client starts the XferRequest. | ||
98 | /// </summary> | ||
99 | /// <param name="fileName"></param> | ||
100 | /// <param name="data"></param> | ||
101 | /// <returns></returns> | ||
93 | public bool AddNewFile(string fileName, byte[] data) | 102 | public bool AddNewFile(string fileName, byte[] data) |
94 | { | 103 | { |
95 | lock (NewFiles) | 104 | lock (NewFiles) |
@@ -97,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
97 | if (NewFiles.ContainsKey(fileName)) | 106 | if (NewFiles.ContainsKey(fileName)) |
98 | { | 107 | { |
99 | NewFiles[fileName].Count++; | 108 | NewFiles[fileName].Count++; |
100 | //Console.WriteLine("AddNewFile " + fileName + " counter=" + NewFiles[fileName].Count); | 109 | NewFiles[fileName].Data = data; |
101 | } | 110 | } |
102 | else | 111 | else |
103 | { | 112 | { |
@@ -105,23 +114,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
105 | fd.Count = 1; | 114 | fd.Count = 1; |
106 | fd.Data = data; | 115 | fd.Data = data; |
107 | NewFiles.Add(fileName, fd); | 116 | NewFiles.Add(fileName, fd); |
108 | //Console.WriteLine("AddNewFile " + fileName); | ||
109 | } | 117 | } |
110 | } | 118 | } |
111 | 119 | ||
112 | // This happens when the Xfer request ends up coming before | ||
113 | // the fileName is added by this method. That may happen when | ||
114 | // the file generation (the event that calle this method) | ||
115 | // takes a long time. In this case, we need to kick the | ||
116 | // Xfer request mannually. | ||
117 | if (Requests.ContainsKey(fileName)) | ||
118 | { | ||
119 | //Console.WriteLine("*** AddNewFile Requests.Contains " + fileName); | ||
120 | |||
121 | RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName); | ||
122 | Requests.Remove(fileName); | ||
123 | } | ||
124 | |||
125 | return true; | 120 | return true; |
126 | } | 121 | } |
127 | 122 | ||
@@ -144,23 +139,17 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
144 | { | 139 | { |
145 | lock (NewFiles) | 140 | lock (NewFiles) |
146 | { | 141 | { |
147 | //Console.WriteLine("---- RequestXfer " + fileName + " ----"); | ||
148 | |||
149 | if (NewFiles.ContainsKey(fileName)) | 142 | if (NewFiles.ContainsKey(fileName)) |
150 | { | 143 | { |
151 | //Console.WriteLine("NewFiles.ContainsKey " + fileName + " with count=" + NewFiles[fileName].Count); | ||
152 | if (!Transfers.ContainsKey(xferID)) | 144 | if (!Transfers.ContainsKey(xferID)) |
153 | { | 145 | { |
154 | //Console.WriteLine("!Transfers.ContainsKey("+xferID+")"); | ||
155 | byte[] fileData = NewFiles[fileName].Data; | 146 | byte[] fileData = NewFiles[fileName].Data; |
156 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | 147 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); |
157 | 148 | ||
158 | Transfers.Add(xferID, transaction); | 149 | Transfers.Add(xferID, transaction); |
159 | 150 | ||
160 | if (transaction.StartSend()) | 151 | if (transaction.StartSend()) |
161 | { | ||
162 | RemoveXferData(xferID); | 152 | RemoveXferData(xferID); |
163 | } | ||
164 | 153 | ||
165 | // The transaction for this file is either complete or on its way | 154 | // The transaction for this file is either complete or on its way |
166 | RemoveOrDecrement(fileName); | 155 | RemoveOrDecrement(fileName); |
@@ -168,42 +157,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
168 | } | 157 | } |
169 | } | 158 | } |
170 | else | 159 | else |
171 | { | 160 | m_log.WarnFormat("[Xfer]: {0} not found", fileName); |
172 | ////Console.WriteLine("*** ! NewFiles.ContainsKey " + fileName); | ||
173 | //if (RequestTime.Count > 0) | ||
174 | //{ | ||
175 | // //Console.WriteLine("RequestTime.Count > 0"); | ||
176 | // TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); | ||
177 | // if (ts.TotalSeconds > 30) | ||
178 | // { | ||
179 | // Console.WriteLine("ts.TotalSeconds > 30"); | ||
180 | // Requests.Remove(RequestTime[0].fileName); | ||
181 | // RequestTime.RemoveAt(0); | ||
182 | // // Do we want to abort this here? | ||
183 | // //remoteClient.SendAbortXfer(xferID); | ||
184 | // } | ||
185 | //} | ||
186 | |||
187 | XferRequest nRequest = new XferRequest(); | ||
188 | nRequest.remoteClient = remoteClient; | ||
189 | nRequest.xferID = xferID; | ||
190 | nRequest.fileName = fileName; | ||
191 | nRequest.timeStamp = DateTime.UtcNow; | ||
192 | nRequest.fileName = fileName; | ||
193 | |||
194 | if (!Requests.ContainsKey(fileName)) | ||
195 | { | ||
196 | //Console.WriteLine("**** !Requests.ContainsKey(" + fileName + ")"); | ||
197 | Requests.Add(fileName, nRequest); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | //Console.WriteLine("**** Requests.ContainsKey(" + fileName + ")"); | ||
202 | Requests.Add(fileName + "-" + counter.ToString(), nRequest); | ||
203 | counter++; | ||
204 | } | ||
205 | |||
206 | } | ||
207 | 161 | ||
208 | } | 162 | } |
209 | } | 163 | } |
@@ -220,15 +174,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
220 | RemoveXferData(xferID); | 174 | RemoveXferData(xferID); |
221 | RemoveOrDecrement(dl.FileName); | 175 | RemoveOrDecrement(dl.FileName); |
222 | } | 176 | } |
223 | else | ||
224 | { | ||
225 | if (Requests.ContainsKey(dl.FileName)) | ||
226 | { | ||
227 | XferRequest req = Requests[dl.FileName]; | ||
228 | req.timeStamp = DateTime.UtcNow; | ||
229 | Requests[dl.FileName] = req; | ||
230 | } | ||
231 | } | ||
232 | } | 177 | } |
233 | } | 178 | } |
234 | } | 179 | } |
@@ -238,19 +183,12 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
238 | // NewFiles must be locked! | 183 | // NewFiles must be locked! |
239 | if (Transfers.ContainsKey(xferID)) | 184 | if (Transfers.ContainsKey(xferID)) |
240 | { | 185 | { |
241 | // Qualifier distinguishes between the OpenMetaverse version and the nested class | ||
242 | |||
243 | XferModule.XferDownLoad xferItem = Transfers[xferID]; | 186 | XferModule.XferDownLoad xferItem = Transfers[xferID]; |
244 | //string filename = xferItem.FileName; | 187 | //string filename = xferItem.FileName; |
245 | Transfers.Remove(xferID); | 188 | Transfers.Remove(xferID); |
246 | xferItem.Data = new byte[0]; // Clear the data | 189 | xferItem.Data = new byte[0]; // Clear the data |
247 | xferItem.DataPointer = 0; | 190 | xferItem.DataPointer = 0; |
248 | 191 | ||
249 | // If the abort comes in | ||
250 | |||
251 | if (Requests.ContainsKey(xferItem.FileName)) | ||
252 | Requests.Remove(xferItem.FileName); | ||
253 | |||
254 | } | 192 | } |
255 | } | 193 | } |
256 | 194 | ||
@@ -272,13 +210,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
272 | if (NewFiles.ContainsKey(fileName)) | 210 | if (NewFiles.ContainsKey(fileName)) |
273 | { | 211 | { |
274 | if (NewFiles[fileName].Count == 1) | 212 | if (NewFiles[fileName].Count == 1) |
275 | { | ||
276 | NewFiles.Remove(fileName); | 213 | NewFiles.Remove(fileName); |
277 | } | ||
278 | else | 214 | else |
279 | { | ||
280 | NewFiles[fileName].Count--; | 215 | NewFiles[fileName].Count--; |
281 | } | ||
282 | } | 216 | } |
283 | } | 217 | } |
284 | 218 | ||