aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2008-09-27 22:05:36 +0000
committerTeravus Ovares2008-09-27 22:05:36 +0000
commit98632ee594670625fbebc0faa49795fdccb9218a (patch)
treee36b3d00e10fc000121cc25df7302046a0a3f848 /OpenSim/Region
parentContinue working on the new EventQueueGetModule. Not finished (or even working) (diff)
downloadopensim-SC_OLD-98632ee594670625fbebc0faa49795fdccb9218a.zip
opensim-SC_OLD-98632ee594670625fbebc0faa49795fdccb9218a.tar.gz
opensim-SC_OLD-98632ee594670625fbebc0faa49795fdccb9218a.tar.bz2
opensim-SC_OLD-98632ee594670625fbebc0faa49795fdccb9218a.tar.xz
* Event queue is now polling..
* returns FAKEEVENT instead of the connection returning a 502. It doesn't like our 502's for some reason.. so, in leau of this.. send it a fake event. * Once again, this is still 'really early' code, so please don't blame us if you have no more threads left.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs65
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs9
3 files changed, 69 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 5a48c90..46d03fb 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -783,7 +783,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
783 ClientLoop(); 783 ClientLoop();
784 } 784 }
785 } 785 }
786 catch (System.Exception e) 786 //Todo set as Generic Exception again.
787 catch (System.BadImageFormatException e)
787 { 788 {
788 if (e is ThreadAbortException) 789 if (e is ThreadAbortException)
789 throw e; 790 throw e;
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
index d60e15a..ebaa406 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
@@ -52,11 +52,19 @@ using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue<OpenMetaverse.Structur
52 52
53namespace OpenSim.Region.Environment.Modules.Framework 53namespace OpenSim.Region.Environment.Modules.Framework
54{ 54{
55 public struct QueueItem
56 {
57 public int id;
58 public LLSDMap body;
59 }
60
55 public class EventQueueGetModule : IEventQueue, IRegionModule 61 public class EventQueueGetModule : IEventQueue, IRegionModule
56 { 62 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 private Scene m_scene = null; 64 private Scene m_scene = null;
59 private IConfigSource m_gConfig; 65 private IConfigSource m_gConfig;
66
67 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
60 68
61 private Dictionary<UUID, BlockingLLSDQueue> queues = new Dictionary<UUID, BlockingLLSDQueue>(); 69 private Dictionary<UUID, BlockingLLSDQueue> queues = new Dictionary<UUID, BlockingLLSDQueue>();
62 70
@@ -83,6 +91,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
83 91
84 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) 92 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
85 { 93 {
94
86 } 95 }
87 96
88 public void PostInitialise() 97 public void PostInitialise()
@@ -147,6 +156,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
147 { 156 {
148 m_log.DebugFormat("[EVENTQUEUE]: Avatar {0} entering parcel {1} in region {2}.", 157 m_log.DebugFormat("[EVENTQUEUE]: Avatar {0} entering parcel {1} in region {2}.",
149 avatar.UUID, localLandID, regionID); 158 avatar.UUID, localLandID, regionID);
159
150 } 160 }
151 161
152 private void MakeChildAgent(ScenePresence avatar) 162 private void MakeChildAgent(ScenePresence avatar)
@@ -164,29 +174,64 @@ namespace OpenSim.Region.Environment.Modules.Framework
164 { 174 {
165 return ProcessQueue(m_dhttpMethod,agentID, caps); 175 return ProcessQueue(m_dhttpMethod,agentID, caps);
166 })); 176 }));
177 Random rnd = new Random(System.Environment.TickCount);
178 lock (m_ids)
179 {
180 if (!m_ids.ContainsKey(agentID))
181 m_ids.Add(agentID, rnd.Next(30000000));
182 }
183
184
185
167 } 186 }
168 187
169 public Hashtable ProcessQueue(Hashtable request,UUID agentID, Caps caps) 188 public Hashtable ProcessQueue(Hashtable request,UUID agentID, Caps caps)
170 { 189 {
171 // TODO: this has to be redone to not busy-wait (and block the thread), 190 // TODO: this has to be redone to not busy-wait (and block the thread),
172 // TODO: as soon as we have a non-blocking way to handle HTTP-requests. 191 // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
192
173 BlockingLLSDQueue queue = GetQueue(agentID); 193 BlockingLLSDQueue queue = GetQueue(agentID);
174 LLSD element = queue.Dequeue(15000); // 15s timeout 194 LLSD element = queue.Dequeue(15000); // 15s timeout
175 195
196
176 String debug = "[EVENTQUEUE]: Got request for agent {0}: [ "; 197 String debug = "[EVENTQUEUE]: Got request for agent {0}: [ ";
177 foreach(object key in request.Keys) 198 foreach(object key in request.Keys)
178 { 199 {
179 debug += key.ToString() + "=" + request[key].ToString() + " "; 200 debug += key.ToString() + "=" + request[key].ToString() + " ";
180 } 201 }
181 m_log.DebugFormat(debug, agentID); 202 //m_log.DebugFormat(debug, agentID);
182 203
183 if (element == null) // didn't have an event in 15s 204 if (element == null) // didn't have an event in 15s
184 { 205 {
206 // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
207 element = EventQueueHelper.KeepAliveEvent();
208
209 ScenePresence avatar;
210 m_scene.TryGetAvatar(agentID, out avatar);
211
212 LLSDArray array = new LLSDArray();
213 array.Add(element);
214 int thisID = m_ids[agentID];
215 while (queue.Count() > 0)
216 {
217 array.Add(queue.Dequeue(1));
218 thisID++;
219 }
220 LLSDMap events = new LLSDMap();
221 events.Add("events", array);
222
223 events.Add("id", new LLSDInteger(thisID));
224 lock (m_ids)
225 {
226 m_ids[agentID] = thisID + 1;
227 }
185 Hashtable responsedata = new Hashtable(); 228 Hashtable responsedata = new Hashtable();
186 responsedata["int_response_code"] = 502; 229 responsedata["int_response_code"] = 200;
187 responsedata["str_response_string"] = "Upstream error:"; 230 responsedata["content_type"] = "application/llsd+xml";
188 responsedata["content_type"] = "text/plain";
189 responsedata["keepalive"] = true; 231 responsedata["keepalive"] = true;
232 responsedata["str_response_string"] = LLSDParser.SerializeXmlString(events);
233 //m_log.DebugFormat("[EVENTQUEUE]: sending fake response for {0}: {1}", agentID, responsedata["str_response_string"]);
234
190 return responsedata; 235 return responsedata;
191 } 236 }
192 else 237 else
@@ -196,14 +241,20 @@ namespace OpenSim.Region.Environment.Modules.Framework
196 241
197 LLSDArray array = new LLSDArray(); 242 LLSDArray array = new LLSDArray();
198 array.Add(element); 243 array.Add(element);
244 int thisID = m_ids[agentID];
199 while (queue.Count() > 0) 245 while (queue.Count() > 0)
200 { 246 {
201 array.Add(queue.Dequeue(1)); 247 array.Add(queue.Dequeue(1));
248 thisID++;
202 } 249 }
203 LLSDMap events = new LLSDMap(); 250 LLSDMap events = new LLSDMap();
204 events.Add("events", array); 251 events.Add("events", array);
205 events.Add("id", new LLSDInteger(1)); // TODO: this seems to be a event sequence-numeber to be ack'd by the client? 252
206 253 events.Add("id", new LLSDInteger(thisID));
254 lock (m_ids)
255 {
256 m_ids[agentID] = thisID + 1;
257 }
207 Hashtable responsedata = new Hashtable(); 258 Hashtable responsedata = new Hashtable();
208 responsedata["int_response_code"] = 200; 259 responsedata["int_response_code"] = 200;
209 responsedata["content_type"] = "application/llsd+xml"; 260 responsedata["content_type"] = "application/llsd+xml";
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs
index 7241cb3..46f7a3f 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs
@@ -54,6 +54,15 @@ namespace OpenSim.Region.Environment
54 llsdMessage.Add("body", llsdBody); 54 llsdMessage.Add("body", llsdBody);
55 55
56 return llsdMessage; 56 return llsdMessage;
57 }
58 public static LLSD KeepAliveEvent()
59 {
60 LLSDMap llsdSimInfo = new LLSDMap();
61 LLSDMap llsdMessage = new LLSDMap(2);
62 llsdMessage.Add("message", new LLSDString("FAKEEVENT"));
63 llsdMessage.Add("body", llsdSimInfo);
64
65 return llsdMessage;
57 } 66 }
58 } 67 }
59} 68}