diff options
author | Teravus Ovares | 2008-09-27 22:05:36 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-09-27 22:05:36 +0000 |
commit | 98632ee594670625fbebc0faa49795fdccb9218a (patch) | |
tree | e36b3d00e10fc000121cc25df7302046a0a3f848 /OpenSim | |
parent | Continue working on the new EventQueueGetModule. Not finished (or even working) (diff) | |
download | opensim-SC-98632ee594670625fbebc0faa49795fdccb9218a.zip opensim-SC-98632ee594670625fbebc0faa49795fdccb9218a.tar.gz opensim-SC-98632ee594670625fbebc0faa49795fdccb9218a.tar.bz2 opensim-SC-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 '')
4 files changed, 73 insertions, 10 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 24bba2b..504ca8b 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs | |||
@@ -991,6 +991,7 @@ namespace OpenSim.Framework.Servers | |||
991 | string responseString = (string)responsedata["str_response_string"]; | 991 | string responseString = (string)responsedata["str_response_string"]; |
992 | string contentType = (string)responsedata["content_type"]; | 992 | string contentType = (string)responsedata["content_type"]; |
993 | 993 | ||
994 | |||
994 | if (responsedata.ContainsKey("keepalive")) | 995 | if (responsedata.ContainsKey("keepalive")) |
995 | response.KeepAlive = true; | 996 | response.KeepAlive = true; |
996 | 997 | ||
@@ -1003,7 +1004,7 @@ namespace OpenSim.Framework.Servers | |||
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | // The client ignores anything but 200 here for web login, so ensure that this is 200 for that | 1006 | // The client ignores anything but 200 here for web login, so ensure that this is 200 for that |
1006 | 1007 | ||
1007 | response.StatusCode = responsecode; | 1008 | response.StatusCode = responsecode; |
1008 | 1009 | ||
1009 | if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) | 1010 | if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) |
@@ -1028,7 +1029,7 @@ namespace OpenSim.Framework.Servers | |||
1028 | response.SendChunked = false; | 1029 | response.SendChunked = false; |
1029 | response.ContentLength64 = buffer.Length; | 1030 | response.ContentLength64 = buffer.Length; |
1030 | response.ContentEncoding = Encoding.UTF8; | 1031 | response.ContentEncoding = Encoding.UTF8; |
1031 | 1032 | ||
1032 | 1033 | ||
1033 | try | 1034 | try |
1034 | { | 1035 | { |
@@ -1042,6 +1043,7 @@ namespace OpenSim.Framework.Servers | |||
1042 | { | 1043 | { |
1043 | response.OutputStream.Close(); | 1044 | response.OutputStream.Close(); |
1044 | } | 1045 | } |
1046 | |||
1045 | } | 1047 | } |
1046 | 1048 | ||
1047 | public void SendHTML404(OSHttpResponse response, string host) | 1049 | public void SendHTML404(OSHttpResponse response, string host) |
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 | ||
53 | namespace OpenSim.Region.Environment.Modules.Framework | 53 | namespace 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 | } |