diff options
author | Teravus Ovares (Dan Olivares) | 2010-12-21 19:15:44 -0500 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2010-12-21 19:15:44 -0500 |
commit | 25ecd62b1feed16d12d6f5e5ef00bddf7dbf0547 (patch) | |
tree | 6da8a5c79266eb5dc1e36baaf95ee1f0c8531f42 /OpenSim/Region/CoreModules | |
parent | What is the point of using different types to express the same damn thing? (diff) | |
download | opensim-SC-25ecd62b1feed16d12d6f5e5ef00bddf7dbf0547.zip opensim-SC-25ecd62b1feed16d12d6f5e5ef00bddf7dbf0547.tar.gz opensim-SC-25ecd62b1feed16d12d6f5e5ef00bddf7dbf0547.tar.bz2 opensim-SC-25ecd62b1feed16d12d6f5e5ef00bddf7dbf0547.tar.xz |
* Adds AbortXfer to the ClientAPI mix
* Adds an item that checks to see if the top request has been there for longer then 30 seconds without an update and sends an AbortXfer if it encounters one. This allows the client to cancel the Xfer on it's side so you can re-select the prim and get the inventory when it fails the first time.
* Some interesting locking... Using NewFiles to lock the rest of them. We'll see how that goes.
* The goal of this is to ensure that Xfers are restartable when they fail. The client will not do that on it's own.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index ef7dce8..57875da 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -97,6 +97,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
97 | NewFiles.Add(fileName, data); | 97 | NewFiles.Add(fileName, data); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | string filename = string.Empty; | ||
100 | 101 | ||
101 | if (Requests.ContainsKey(fileName)) | 102 | if (Requests.ContainsKey(fileName)) |
102 | { | 103 | { |
@@ -113,6 +114,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
113 | { | 114 | { |
114 | client.OnRequestXfer += RequestXfer; | 115 | client.OnRequestXfer += RequestXfer; |
115 | client.OnConfirmXfer += AckPacket; | 116 | client.OnConfirmXfer += AckPacket; |
117 | client.OnAbortXfer += AbortXfer; | ||
116 | } | 118 | } |
117 | 119 | ||
118 | /// <summary> | 120 | /// <summary> |
@@ -125,6 +127,17 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
125 | { | 127 | { |
126 | lock (NewFiles) | 128 | lock (NewFiles) |
127 | { | 129 | { |
130 | if (RequestTime.Count > 0) | ||
131 | { | ||
132 | TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); | ||
133 | if (ts.TotalSeconds > 30) | ||
134 | { | ||
135 | ulong zxferid = RequestTime[0].xferID; | ||
136 | remoteClient.SendAbortXferPacket(zxferid); | ||
137 | RemoveXferData(zxferid); | ||
138 | } | ||
139 | } | ||
140 | |||
128 | if (NewFiles.ContainsKey(fileName)) | 141 | if (NewFiles.ContainsKey(fileName)) |
129 | { | 142 | { |
130 | if (!Transfers.ContainsKey(xferID)) | 143 | if (!Transfers.ContainsKey(xferID)) |
@@ -137,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
137 | 150 | ||
138 | if (transaction.StartSend()) | 151 | if (transaction.StartSend()) |
139 | { | 152 | { |
140 | Transfers.Remove(xferID); | 153 | RemoveXferData(xferID); |
141 | } | 154 | } |
142 | } | 155 | } |
143 | } | 156 | } |
@@ -150,6 +163,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
150 | { | 163 | { |
151 | Requests.Remove(RequestTime[0].fileName); | 164 | Requests.Remove(RequestTime[0].fileName); |
152 | RequestTime.RemoveAt(0); | 165 | RequestTime.RemoveAt(0); |
166 | // Do we want to abort this here? | ||
167 | //remoteClient.SendAbortXfer(xferID); | ||
153 | } | 168 | } |
154 | } | 169 | } |
155 | 170 | ||
@@ -165,22 +180,69 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
165 | } | 180 | } |
166 | 181 | ||
167 | } | 182 | } |
183 | |||
168 | } | 184 | } |
169 | } | 185 | } |
170 | 186 | ||
171 | public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) | 187 | public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) |
172 | { | 188 | { |
173 | if (Transfers.ContainsKey(xferID)) | 189 | lock (NewFiles) // This is actually to lock Transfers |
174 | { | 190 | { |
175 | if (Transfers[xferID].AckPacket(packet)) | 191 | if (Transfers.ContainsKey(xferID)) |
176 | { | 192 | { |
193 | XferDownLoad dl = Transfers[xferID]; | ||
194 | if (Transfers[xferID].AckPacket(packet)) | ||
177 | { | 195 | { |
178 | Transfers.Remove(xferID); | 196 | { |
197 | RemoveXferData(xferID); | ||
198 | } | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | |||
203 | if (Requests.ContainsKey(dl.FileName)) | ||
204 | { | ||
205 | // | ||
206 | XferRequest req = Requests[dl.FileName]; | ||
207 | req.timeStamp = DateTime.UtcNow; | ||
208 | Requests[dl.FileName] = req; | ||
209 | } | ||
179 | } | 210 | } |
180 | } | 211 | } |
181 | } | 212 | } |
182 | } | 213 | } |
183 | 214 | ||
215 | private void RemoveXferData(ulong xferID) | ||
216 | { | ||
217 | // NewFiles must be locked! | ||
218 | if (Transfers.ContainsKey(xferID)) | ||
219 | { | ||
220 | // Qualifier distinguishes between the OpenMetaverse version and the nested class | ||
221 | |||
222 | XferModule.XferDownLoad xferItem = Transfers[xferID]; | ||
223 | //string filename = xferItem.FileName; | ||
224 | Transfers.Remove(xferID); | ||
225 | xferItem.Data = new byte[0]; // Clear the data | ||
226 | xferItem.DataPointer = 0; | ||
227 | |||
228 | // If the abort comes in | ||
229 | if (NewFiles.ContainsKey(xferItem.FileName)) | ||
230 | NewFiles.Remove(xferItem.FileName); | ||
231 | |||
232 | if (Requests.ContainsKey(xferItem.FileName)) | ||
233 | Requests.Remove(xferItem.FileName); | ||
234 | |||
235 | } | ||
236 | } | ||
237 | |||
238 | public void AbortXfer(IClientAPI remoteClient, ulong xferID) | ||
239 | { | ||
240 | lock (NewFiles) | ||
241 | { | ||
242 | RemoveXferData(xferID); | ||
243 | } | ||
244 | } | ||
245 | |||
184 | #region Nested type: XferDownLoad | 246 | #region Nested type: XferDownLoad |
185 | 247 | ||
186 | public class XferDownLoad | 248 | public class XferDownLoad |