diff options
author | Melanie | 2010-12-21 23:09:12 +0000 |
---|---|---|
committer | Melanie | 2010-12-21 23:09:12 +0000 |
commit | e9382c293936ff7faa34c5d70db97f24b1339755 (patch) | |
tree | 944d15d068d33f0a63110b62fe4f0e598dec3355 /OpenSim/Region/CoreModules/Agent | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | * Adds AbortXfer to the ClientAPI mix (diff) | |
download | opensim-SC-e9382c293936ff7faa34c5d70db97f24b1339755.zip opensim-SC-e9382c293936ff7faa34c5d70db97f24b1339755.tar.gz opensim-SC-e9382c293936ff7faa34c5d70db97f24b1339755.tar.bz2 opensim-SC-e9382c293936ff7faa34c5d70db97f24b1339755.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-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 |