aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs45
1 files changed, 43 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index 834aa14..ef7dce8 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -38,9 +38,20 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
38 public class XferModule : IRegionModule, IXfer 38 public class XferModule : IRegionModule, IXfer
39 { 39 {
40 private Scene m_scene; 40 private Scene m_scene;
41 private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>();
42 private List<XferRequest> RequestTime = new List<XferRequest>();
41 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); 43 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
42 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); 44 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
45
43 46
47 public struct XferRequest
48 {
49 public IClientAPI remoteClient;
50 public ulong xferID;
51 public string fileName;
52 public DateTime timeStamp;
53 }
54
44 #region IRegionModule Members 55 #region IRegionModule Members
45 56
46 public void Initialise(Scene scene, IConfigSource config) 57 public void Initialise(Scene scene, IConfigSource config)
@@ -86,6 +97,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
86 NewFiles.Add(fileName, data); 97 NewFiles.Add(fileName, data);
87 } 98 }
88 } 99 }
100
101 if (Requests.ContainsKey(fileName))
102 {
103 RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName);
104 Requests.Remove(fileName);
105 }
106
89 return true; 107 return true;
90 } 108 }
91 109
@@ -105,7 +123,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
105 /// <param name="fileName"></param> 123 /// <param name="fileName"></param>
106 public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) 124 public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
107 { 125 {
108
109 lock (NewFiles) 126 lock (NewFiles)
110 { 127 {
111 if (NewFiles.ContainsKey(fileName)) 128 if (NewFiles.ContainsKey(fileName))
@@ -114,6 +131,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
114 { 131 {
115 byte[] fileData = NewFiles[fileName]; 132 byte[] fileData = NewFiles[fileName];
116 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); 133 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
134
117 Transfers.Add(xferID, transaction); 135 Transfers.Add(xferID, transaction);
118 NewFiles.Remove(fileName); 136 NewFiles.Remove(fileName);
119 137
@@ -123,6 +141,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
123 } 141 }
124 } 142 }
125 } 143 }
144 else
145 {
146 if (RequestTime.Count > 0)
147 {
148 TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks);
149 if (ts.TotalSeconds > 30)
150 {
151 Requests.Remove(RequestTime[0].fileName);
152 RequestTime.RemoveAt(0);
153 }
154 }
155
156 if (!Requests.ContainsKey(fileName))
157 {
158 XferRequest nRequest = new XferRequest();
159 nRequest.remoteClient = remoteClient;
160 nRequest.xferID = xferID;
161 nRequest.fileName = fileName;
162 nRequest.timeStamp = DateTime.UtcNow;
163 Requests.Add(fileName, nRequest);
164 RequestTime.Add(nRequest);
165 }
166
167 }
126 } 168 }
127 } 169 }
128 170
@@ -177,7 +219,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
177 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); 219 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
178 Array.Copy(Data, 0, transferData, 4, Data.Length); 220 Array.Copy(Data, 0, transferData, 4, Data.Length);
179 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); 221 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
180
181 complete = true; 222 complete = true;
182 } 223 }
183 else 224 else