aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs159
1 files changed, 32 insertions, 127 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index da1ccb3..4154ef2 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -281,25 +281,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
281 m_shouldCollectStats = false; 281 m_shouldCollectStats = false;
282 if (config != null) 282 if (config != null)
283 { 283 {
284 if (config.Contains("enabled") && config.GetBoolean("enabled")) 284 m_shouldCollectStats = config.GetBoolean("Enabled", false);
285 { 285 binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("packet_headers_period_seconds", 300));
286 if (config.Contains("collect_packet_headers")) 286 binStatsDir = config.GetString("stats_dir", ".");
287 m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); 287 m_aggregatedBWStats = config.GetBoolean("aggregatedBWStats", false);
288 if (config.Contains("packet_headers_period_seconds")) 288 }
289 { 289 #endregion BinaryStats
290 binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds"));
291 }
292 if (config.Contains("stats_dir"))
293 {
294 binStatsDir = config.GetString("stats_dir");
295 }
296 }
297 else
298 {
299 m_shouldCollectStats = false;
300 }
301 }
302 #endregion BinaryStats
303 290
304 m_throttle = new TokenBucket(null, sceneThrottleBps); 291 m_throttle = new TokenBucket(null, sceneThrottleBps);
305 ThrottleRates = new ThrottleRates(configSource); 292 ThrottleRates = new ThrottleRates(configSource);
@@ -1309,8 +1296,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1309 static object binStatsLogLock = new object(); 1296 static object binStatsLogLock = new object();
1310 static string binStatsDir = ""; 1297 static string binStatsDir = "";
1311 1298
1299 //for Aggregated In/Out BW logging
1300 static bool m_aggregatedBWStats = false;
1301 static long m_aggregatedBytesIn = 0;
1302 static long m_aggregatedByestOut = 0;
1303 static object aggBWStatsLock = new object();
1304
1305 public static long AggregatedLLUDPBytesIn
1306 {
1307 get { return m_aggregatedBytesIn; }
1308 }
1309 public static long AggregatedLLUDPBytesOut
1310 {
1311 get {return m_aggregatedByestOut;}
1312 }
1313
1312 public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) 1314 public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size)
1313 { 1315 {
1316 if (m_aggregatedBWStats)
1317 {
1318 lock (aggBWStatsLock)
1319 {
1320 if (incoming)
1321 m_aggregatedBytesIn += size;
1322 else
1323 m_aggregatedByestOut += size;
1324 }
1325 }
1326
1314 if (!m_shouldCollectStats) return; 1327 if (!m_shouldCollectStats) return;
1315 1328
1316 // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size 1329 // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size
@@ -1903,112 +1916,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1903 } 1916 }
1904 } 1917 }
1905 } 1918 }
1906
1907 internal class DoubleQueue<T> where T:class
1908 {
1909 private Queue<T> m_lowQueue = new Queue<T>();
1910 private Queue<T> m_highQueue = new Queue<T>();
1911
1912 private object m_syncRoot = new object();
1913 private Semaphore m_s = new Semaphore(0, 1);
1914
1915 public DoubleQueue()
1916 {
1917 }
1918
1919 public virtual int Count
1920 {
1921 get { return m_highQueue.Count + m_lowQueue.Count; }
1922 }
1923
1924 public virtual void Enqueue(T data)
1925 {
1926 Enqueue(m_lowQueue, data);
1927 }
1928
1929 public virtual void EnqueueLow(T data)
1930 {
1931 Enqueue(m_lowQueue, data);
1932 }
1933
1934 public virtual void EnqueueHigh(T data)
1935 {
1936 Enqueue(m_highQueue, data);
1937 }
1938
1939 private void Enqueue(Queue<T> q, T data)
1940 {
1941 lock (m_syncRoot)
1942 {
1943 m_lowQueue.Enqueue(data);
1944 m_s.WaitOne(0);
1945 m_s.Release();
1946 }
1947 }
1948
1949 public virtual T Dequeue()
1950 {
1951 return Dequeue(Timeout.Infinite);
1952 }
1953
1954 public virtual T Dequeue(int tmo)
1955 {
1956 return Dequeue(TimeSpan.FromMilliseconds(tmo));
1957 }
1958
1959 public virtual T Dequeue(TimeSpan wait)
1960 {
1961 T res = null;
1962
1963 if (!Dequeue(wait, ref res))
1964 return null;
1965
1966 return res;
1967 }
1968
1969 public bool Dequeue(int timeout, ref T res)
1970 {
1971 return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
1972 }
1973
1974 public bool Dequeue(TimeSpan wait, ref T res)
1975 {
1976 if (!m_s.WaitOne(wait))
1977 return false;
1978
1979 lock (m_syncRoot)
1980 {
1981 if (m_highQueue.Count > 0)
1982 res = m_highQueue.Dequeue();
1983 else
1984 res = m_lowQueue.Dequeue();
1985
1986 if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
1987 return true;
1988
1989 try
1990 {
1991 m_s.Release();
1992 }
1993 catch
1994 {
1995 }
1996
1997 return true;
1998 }
1999 }
2000
2001 public virtual void Clear()
2002 {
2003
2004 lock (m_syncRoot)
2005 {
2006 // Make sure sem count is 0
2007 m_s.WaitOne(0);
2008
2009 m_lowQueue.Clear();
2010 m_highQueue.Clear();
2011 }
2012 }
2013 }
2014} 1919}