aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
diff options
context:
space:
mode:
authorDr Scofield2009-02-17 18:27:01 +0000
committerDr Scofield2009-02-17 18:27:01 +0000
commit6fbc1f2b23a2b75c87fe901a47845958af990368 (patch)
treee3b505c263716147c6963f791a65b02bb0a6688c /OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
parent* Assign incoming items with a random UUID so that archives can be loaded mor... (diff)
downloadopensim-SC_OLD-6fbc1f2b23a2b75c87fe901a47845958af990368.zip
opensim-SC_OLD-6fbc1f2b23a2b75c87fe901a47845958af990368.tar.gz
opensim-SC_OLD-6fbc1f2b23a2b75c87fe901a47845958af990368.tar.bz2
opensim-SC_OLD-6fbc1f2b23a2b75c87fe901a47845958af990368.tar.xz
- additional code to get ConciergeModule to do truly async broker updates
- adding watchdog timer async web request - making broker update timeout configurable
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs76
1 files changed, 63 insertions, 13 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index 83c3c34..51aa8f8 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -72,6 +72,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
72 private string m_announceLeaving = "{0} leaves {1} (back to {2} visitors in this region)"; 72 private string m_announceLeaving = "{0} leaves {1} (back to {2} visitors in this region)";
73 private string m_xmlRpcPassword = String.Empty; 73 private string m_xmlRpcPassword = String.Empty;
74 private string m_brokerURI = String.Empty; 74 private string m_brokerURI = String.Empty;
75 private int m_brokerUpdateTimeout = 300;
75 76
76 internal object m_syncy = new object(); 77 internal object m_syncy = new object();
77 78
@@ -126,6 +127,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
126 m_announceLeaving = m_config.GetString("announce_leaving", m_announceLeaving); 127 m_announceLeaving = m_config.GetString("announce_leaving", m_announceLeaving);
127 m_xmlRpcPassword = m_config.GetString("password", m_xmlRpcPassword); 128 m_xmlRpcPassword = m_config.GetString("password", m_xmlRpcPassword);
128 m_brokerURI = m_config.GetString("broker", m_brokerURI); 129 m_brokerURI = m_config.GetString("broker", m_brokerURI);
130 m_brokerUpdateTimeout = m_config.GetInt("broker_timeout", m_brokerUpdateTimeout);
129 131
130 m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami); 132 m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami);
131 133
@@ -355,6 +357,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
355 } 357 }
356 } 358 }
357 359
360 internal class BrokerState
361 {
362 public string Uri;
363 public string Payload;
364 public HttpWebRequest Poster;
365 public Timer Timer;
366
367 public BrokerState(string uri, string payload, HttpWebRequest poster)
368 {
369 Uri = uri;
370 Payload = payload;
371 Poster = poster;
372 }
373 }
374
358 protected void UpdateBroker(IScene scene) 375 protected void UpdateBroker(IScene scene)
359 { 376 {
360 if (String.IsNullOrEmpty(m_brokerURI)) 377 if (String.IsNullOrEmpty(m_brokerURI))
@@ -411,13 +428,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
411 updatePost.ContentLength = payload.Length; 428 updatePost.ContentLength = payload.Length;
412 updatePost.UserAgent = "OpenSim.Concierge"; 429 updatePost.UserAgent = "OpenSim.Concierge";
413 430
431
432 BrokerState bs = new BrokerState(uri, payload, updatePost);
433 bs.Timer = new Timer(delegate(object state)
434 {
435 BrokerState b = state as BrokerState;
436 b.Poster.Abort();
437 b.Timer.Dispose();
438 m_log.Debug("[Concierge]: async broker POST abort due to timeout");
439 }, bs, m_brokerUpdateTimeout * 1000, Timeout.Infinite);
440
414 try 441 try
415 { 442 {
416 StreamWriter payloadStream = new StreamWriter(updatePost.GetRequestStream()); 443 updatePost.BeginGetRequestStream(UpdateBrokerSend, bs);
417 payloadStream.Write(payload);
418 payloadStream.Close();
419
420 updatePost.BeginGetResponse(UpdateBrokerDone, updatePost);
421 m_log.DebugFormat("[Concierge] async broker POST to {0} started", uri); 444 m_log.DebugFormat("[Concierge] async broker POST to {0} started", uri);
422 } 445 }
423 catch (WebException we) 446 catch (WebException we)
@@ -426,33 +449,60 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
426 } 449 }
427 } 450 }
428 451
452 private void UpdateBrokerSend(IAsyncResult result)
453 {
454 BrokerState bs = null;
455 try
456 {
457 bs = result.AsyncState as BrokerState;
458 string payload = bs.Payload;
459 HttpWebRequest updatePost = bs.Poster;
460
461 using(StreamWriter payloadStream = new StreamWriter(updatePost.EndGetRequestStream(result)))
462 {
463 payloadStream.Write(payload);
464 payloadStream.Close();
465 }
466 updatePost.BeginGetResponse(UpdateBrokerDone, bs);
467 }
468 catch (WebException we)
469 {
470 m_log.DebugFormat("[Concierge]: async broker POST to {0} failed: {1}", bs.Uri, we.Status);
471 }
472 catch (Exception)
473 {
474 m_log.DebugFormat("[Concierge]: async broker POST to {0} failed", bs.Uri);
475 }
476 }
477
429 private void UpdateBrokerDone(IAsyncResult result) 478 private void UpdateBrokerDone(IAsyncResult result)
430 { 479 {
431 HttpWebRequest updatePost = null; 480 BrokerState bs = null;
432 try 481 try
433 { 482 {
434 updatePost = result.AsyncState as HttpWebRequest; 483 bs = result.AsyncState as BrokerState;
484 HttpWebRequest updatePost = bs.Poster;
435 using (HttpWebResponse response = updatePost.EndGetResponse(result) as HttpWebResponse) 485 using (HttpWebResponse response = updatePost.EndGetResponse(result) as HttpWebResponse)
436 { 486 {
437 m_log.DebugFormat("[Concierge] broker update: status {0}", response.StatusCode); 487 m_log.DebugFormat("[Concierge] broker update: status {0}", response.StatusCode);
438 } 488 }
489 bs.Timer.Dispose();
439 } 490 }
440 catch (WebException we) 491 catch (WebException we)
441 { 492 {
442 string uri = updatePost.RequestUri.OriginalString; 493 m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status);
443 m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", uri, we.Status);
444 if (null != we.Response) 494 if (null != we.Response)
445 { 495 {
446 using (HttpWebResponse resp = we.Response as HttpWebResponse) 496 using (HttpWebResponse resp = we.Response as HttpWebResponse)
447 { 497 {
448 m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", uri, resp.StatusCode); 498 m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode);
449 m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", uri, resp.StatusDescription); 499 m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription);
450 m_log.ErrorFormat("[Concierge] response from {0} server: {1}", uri, resp.Server); 500 m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server);
451 501
452 if (resp.ContentLength > 0) 502 if (resp.ContentLength > 0)
453 { 503 {
454 StreamReader content = new StreamReader(resp.GetResponseStream()); 504 StreamReader content = new StreamReader(resp.GetResponseStream());
455 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", uri, content.ReadToEnd()); 505 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
456 content.Close(); 506 content.Close();
457 } 507 }
458 } 508 }