aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs2
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs71
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs1
3 files changed, 66 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 58094d3..552c51e 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -713,7 +713,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
713 scene.Name, 713 scene.Name,
714 StatType.Pull, 714 StatType.Pull,
715 MeasuresOfInterest.AverageChangeOverTime, 715 MeasuresOfInterest.AverageChangeOverTime,
716 stat => stat.Value = packetInbox.Count, 716 stat => {try{stat.Value = packetInbox.Count;}catch{}},
717 StatVerbosity.Debug)); 717 StatVerbosity.Debug));
718 718
719 // XXX: These stats are also pool stats but we register them separately since they are currently not 719 // XXX: These stats are also pool stats but we register them separately since they are currently not
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs
index fb60e9e..817170f 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Region.DataSnapshot
45// private Scene m_scene = null; 45// private Scene m_scene = null;
46 private DataSnapshotManager m_externalData = null; 46 private DataSnapshotManager m_externalData = null;
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private ExpiringCache<string, int> throotleGen = new ExpiringCache<string, int>();
48 49
49 public DataRequestHandler(Scene scene, DataSnapshotManager externalData) 50 public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
50 { 51 {
@@ -61,25 +62,81 @@ namespace OpenSim.Region.DataSnapshot
61 62
62 } 63 }
63 64
65 private string GetClientString(Hashtable request)
66 {
67 string clientstring = "";
68 if (!request.ContainsKey("headers"))
69 return clientstring;
70
71 Hashtable requestinfo = (Hashtable)request["headers"];
72 if (requestinfo.ContainsKey("x-forwarded-for"))
73 {
74 object str = requestinfo["x-forwarded-for"];
75 if (str != null)
76 {
77 if (!string.IsNullOrEmpty(str.ToString()))
78 {
79 return str.ToString();
80 }
81 }
82 }
83 if (!requestinfo.ContainsKey("remote_addr"))
84 return clientstring;
85
86 object remote_addrobj = requestinfo["remote_addr"];
87 if (remote_addrobj != null)
88 {
89 if (!string.IsNullOrEmpty(remote_addrobj.ToString()))
90 {
91 clientstring = remote_addrobj.ToString();
92 }
93 }
94
95 return clientstring;
96 }
97
64 public Hashtable OnGetSnapshot(Hashtable keysvals) 98 public Hashtable OnGetSnapshot(Hashtable keysvals)
65 { 99 {
66 string snapObj = (string)keysvals["region"];
67 m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj);
68 Hashtable reply = new Hashtable(); 100 Hashtable reply = new Hashtable();
69 int statuscode = 200; 101 string reqtag;
102 string snapObj = (string)keysvals["region"];
103 if(string.IsNullOrWhiteSpace(snapObj))
104 reqtag = GetClientString(keysvals);
105 else
106 reqtag = snapObj + GetClientString(keysvals);
107
108
109 if(!string.IsNullOrWhiteSpace(reqtag))
110 {
111 if(throotleGen.Contains(reqtag))
112 {
113 reply["str_response_string"] = "Please try your request again later";
114 reply["int_response_code"] = 503;
115 reply["content_type"] = "text/plain";
116 m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
117 return reply;
118 }
119
120 throotleGen.AddOrUpdate(reqtag, 0, 60);
121 }
122
123 if(string.IsNullOrWhiteSpace(snapObj))
124 m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all");
125 else
126 m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj);
70 127
71 XmlDocument response = m_externalData.GetSnapshot(snapObj); 128 XmlDocument response = m_externalData.GetSnapshot(snapObj);
72 if(response == null) 129 if(response == null)
73 { 130 {
74 reply["str_response_string"] = string.Empty; 131 reply["str_response_string"] = "Please try your request again later";
75 reply["int_response_code"] = 503; 132 reply["int_response_code"] = 503;
76 reply["content_type"] = "text"; 133 reply["content_type"] = "text/plain";
77 m_log.Debug("[DATASNAPSHOT] Collection request reply try later"); 134 m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
78 return reply; 135 return reply;
79 } 136 }
80 137
81 reply["str_response_string"] = response.OuterXml; 138 reply["str_response_string"] = response.OuterXml;
82 reply["int_response_code"] = statuscode; 139 reply["int_response_code"] = 200;
83 reply["content_type"] = "text/xml"; 140 reply["content_type"] = "text/xml";
84 return reply; 141 return reply;
85 } 142 }
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
index 88fa1ae..bf9c14d 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
@@ -321,6 +321,7 @@ namespace OpenSim.Region.DataSnapshot
321 /** 321 /**
322 * Reply to the http request 322 * Reply to the http request
323 */ 323 */
324
324 public XmlDocument GetSnapshot(string regionName) 325 public XmlDocument GetSnapshot(string regionName)
325 { 326 {
326 if(!Monitor.TryEnter(m_serializeGen,30000)) 327 if(!Monitor.TryEnter(m_serializeGen,30000))