diff options
author | Melanie | 2013-02-26 13:34:20 +0000 |
---|---|---|
committer | Melanie | 2013-02-26 13:34:20 +0000 |
commit | 54ee95dd8e6649723d92ac893e1699d34822cd80 (patch) | |
tree | d1d15e17c0a04bef247bfe8e6e0cffd3f8460ff1 /OpenSim/Framework | |
parent | Make sure state machine is reset if crossing is aborted (diff) | |
parent | BulletSim: tweeks to make avatar jump work better. (diff) | |
download | opensim-SC_OLD-54ee95dd8e6649723d92ac893e1699d34822cd80.zip opensim-SC_OLD-54ee95dd8e6649723d92ac893e1699d34822cd80.tar.gz opensim-SC_OLD-54ee95dd8e6649723d92ac893e1699d34822cd80.tar.bz2 opensim-SC_OLD-54ee95dd8e6649723d92ac893e1699d34822cd80.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Framework')
-rwxr-xr-x | OpenSim/Framework/Monitoring/Stats/CounterStat.cs | 439 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/Stats/Stat.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 29 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 27 |
4 files changed, 274 insertions, 223 deletions
diff --git a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs index d81f182..caea30d 100755 --- a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs +++ b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs | |||
@@ -1,211 +1,228 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | 30 | using System.Linq; |
31 | using System.Text; | 31 | using System.Text; |
32 | 32 | ||
33 | using OpenMetaverse.StructuredData; | 33 | using OpenMetaverse.StructuredData; |
34 | 34 | ||
35 | namespace OpenSim.Framework.Monitoring | 35 | namespace OpenSim.Framework.Monitoring |
36 | { | 36 | { |
37 | // Create a time histogram of events. The histogram is built in a wrap-around | 37 | // Create a time histogram of events. The histogram is built in a wrap-around |
38 | // array of equally distributed buckets. | 38 | // array of equally distributed buckets. |
39 | // For instance, a minute long histogram of second sized buckets would be: | 39 | // For instance, a minute long histogram of second sized buckets would be: |
40 | // new EventHistogram(60, 1000) | 40 | // new EventHistogram(60, 1000) |
41 | public class EventHistogram | 41 | public class EventHistogram |
42 | { | 42 | { |
43 | private int m_timeBase; | 43 | private int m_timeBase; |
44 | private int m_numBuckets; | 44 | private int m_numBuckets; |
45 | private int m_bucketMilliseconds; | 45 | private int m_bucketMilliseconds; |
46 | private int m_lastBucket; | 46 | private int m_lastBucket; |
47 | private int m_totalHistogramMilliseconds; | 47 | private int m_totalHistogramMilliseconds; |
48 | private long[] m_histogram; | 48 | private long[] m_histogram; |
49 | private object histoLock = new object(); | 49 | private object histoLock = new object(); |
50 | 50 | ||
51 | public EventHistogram(int numberOfBuckets, int millisecondsPerBucket) | 51 | public EventHistogram(int numberOfBuckets, int millisecondsPerBucket) |
52 | { | 52 | { |
53 | m_numBuckets = numberOfBuckets; | 53 | m_numBuckets = numberOfBuckets; |
54 | m_bucketMilliseconds = millisecondsPerBucket; | 54 | m_bucketMilliseconds = millisecondsPerBucket; |
55 | m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds; | 55 | m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds; |
56 | 56 | ||
57 | m_histogram = new long[m_numBuckets]; | 57 | m_histogram = new long[m_numBuckets]; |
58 | Zero(); | 58 | Zero(); |
59 | m_lastBucket = 0; | 59 | m_lastBucket = 0; |
60 | m_timeBase = Util.EnvironmentTickCount(); | 60 | m_timeBase = Util.EnvironmentTickCount(); |
61 | } | 61 | } |
62 | 62 | ||
63 | public void Event() | 63 | public void Event() |
64 | { | 64 | { |
65 | this.Event(1); | 65 | this.Event(1); |
66 | } | 66 | } |
67 | 67 | ||
68 | // Record an event at time 'now' in the histogram. | 68 | // Record an event at time 'now' in the histogram. |
69 | public void Event(int cnt) | 69 | public void Event(int cnt) |
70 | { | 70 | { |
71 | lock (histoLock) | 71 | lock (histoLock) |
72 | { | 72 | { |
73 | // The time as displaced from the base of the histogram | 73 | // The time as displaced from the base of the histogram |
74 | int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase); | 74 | int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase); |
75 | 75 | ||
76 | // If more than the total time of the histogram, we just start over | 76 | // If more than the total time of the histogram, we just start over |
77 | if (bucketTime > m_totalHistogramMilliseconds) | 77 | if (bucketTime > m_totalHistogramMilliseconds) |
78 | { | 78 | { |
79 | Zero(); | 79 | Zero(); |
80 | m_lastBucket = 0; | 80 | m_lastBucket = 0; |
81 | m_timeBase = Util.EnvironmentTickCount(); | 81 | m_timeBase = Util.EnvironmentTickCount(); |
82 | } | 82 | } |
83 | else | 83 | else |
84 | { | 84 | { |
85 | // To which bucket should we add this event? | 85 | // To which bucket should we add this event? |
86 | int bucket = bucketTime / m_bucketMilliseconds; | 86 | int bucket = bucketTime / m_bucketMilliseconds; |
87 | 87 | ||
88 | // Advance m_lastBucket to the new bucket. Zero any buckets skipped over. | 88 | // Advance m_lastBucket to the new bucket. Zero any buckets skipped over. |
89 | while (bucket != m_lastBucket) | 89 | while (bucket != m_lastBucket) |
90 | { | 90 | { |
91 | // Zero from just after the last bucket to the new bucket or the end | 91 | // Zero from just after the last bucket to the new bucket or the end |
92 | for (int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++) | 92 | for (int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++) |
93 | { | 93 | { |
94 | m_histogram[jj] = 0; | 94 | m_histogram[jj] = 0; |
95 | } | 95 | } |
96 | m_lastBucket = bucket; | 96 | m_lastBucket = bucket; |
97 | // If the new bucket is off the end, wrap around to the beginning | 97 | // If the new bucket is off the end, wrap around to the beginning |
98 | if (bucket > m_numBuckets) | 98 | if (bucket > m_numBuckets) |
99 | { | 99 | { |
100 | bucket -= m_numBuckets; | 100 | bucket -= m_numBuckets; |
101 | m_lastBucket = 0; | 101 | m_lastBucket = 0; |
102 | m_histogram[m_lastBucket] = 0; | 102 | m_histogram[m_lastBucket] = 0; |
103 | m_timeBase += m_totalHistogramMilliseconds; | 103 | m_timeBase += m_totalHistogramMilliseconds; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | } | 106 | } |
107 | m_histogram[m_lastBucket] += cnt; | 107 | m_histogram[m_lastBucket] += cnt; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | // Get a copy of the current histogram | 111 | // Get a copy of the current histogram |
112 | public long[] GetHistogram() | 112 | public long[] GetHistogram() |
113 | { | 113 | { |
114 | long[] ret = new long[m_numBuckets]; | 114 | long[] ret = new long[m_numBuckets]; |
115 | lock (histoLock) | 115 | lock (histoLock) |
116 | { | 116 | { |
117 | int indx = m_lastBucket + 1; | 117 | int indx = m_lastBucket + 1; |
118 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) | 118 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) |
119 | { | 119 | { |
120 | if (indx >= m_numBuckets) | 120 | if (indx >= m_numBuckets) |
121 | indx = 0; | 121 | indx = 0; |
122 | ret[ii] = m_histogram[indx]; | 122 | ret[ii] = m_histogram[indx]; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | return ret; | 125 | return ret; |
126 | } | 126 | } |
127 | 127 | ||
128 | // Get a copy of the current histogram | 128 | public OSDMap GetHistogramAsOSDMap() |
129 | public OSDArray GetHistogramAsOSDArray() | 129 | { |
130 | { | 130 | OSDMap ret = new OSDMap(); |
131 | OSDArray ret = new OSDArray(m_numBuckets); | 131 | |
132 | lock (histoLock) | 132 | ret.Add("Buckets", OSD.FromInteger(m_numBuckets)); |
133 | { | 133 | ret.Add("BucketMilliseconds", OSD.FromInteger(m_bucketMilliseconds)); |
134 | int indx = m_lastBucket + 1; | 134 | ret.Add("TotalMilliseconds", OSD.FromInteger(m_totalHistogramMilliseconds)); |
135 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) | 135 | |
136 | { | 136 | // Compute a number for the first bucket in the histogram. |
137 | if (indx >= m_numBuckets) | 137 | // This will allow readers to know how this histogram relates to any previously read histogram. |
138 | indx = 0; | 138 | int baseBucketNum = (m_timeBase / m_bucketMilliseconds) + m_lastBucket + 1; |
139 | ret[ii] = OSD.FromLong(m_histogram[indx]); | 139 | ret.Add("BaseNumber", OSD.FromInteger(baseBucketNum)); |
140 | } | 140 | |
141 | } | 141 | ret.Add("Values", GetHistogramAsOSDArray()); |
142 | return ret; | 142 | |
143 | } | 143 | return ret; |
144 | 144 | } | |
145 | // Zero out the histogram | 145 | // Get a copy of the current histogram |
146 | public void Zero() | 146 | public OSDArray GetHistogramAsOSDArray() |
147 | { | 147 | { |
148 | lock (histoLock) | 148 | OSDArray ret = new OSDArray(m_numBuckets); |
149 | { | 149 | lock (histoLock) |
150 | for (int ii = 0; ii < m_numBuckets; ii++) | 150 | { |
151 | m_histogram[ii] = 0; | 151 | int indx = m_lastBucket + 1; |
152 | } | 152 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) |
153 | } | 153 | { |
154 | } | 154 | if (indx >= m_numBuckets) |
155 | 155 | indx = 0; | |
156 | // A statistic that wraps a counter. | 156 | ret[ii] = OSD.FromLong(m_histogram[indx]); |
157 | // Built this way mostly so histograms and history can be created. | 157 | } |
158 | public class CounterStat : Stat | 158 | } |
159 | { | 159 | return ret; |
160 | private SortedDictionary<string, EventHistogram> m_histograms; | 160 | } |
161 | private object counterLock = new object(); | 161 | |
162 | 162 | // Zero out the histogram | |
163 | public CounterStat( | 163 | public void Zero() |
164 | string shortName, | 164 | { |
165 | string name, | 165 | lock (histoLock) |
166 | string description, | 166 | { |
167 | string unitName, | 167 | for (int ii = 0; ii < m_numBuckets; ii++) |
168 | string category, | 168 | m_histogram[ii] = 0; |
169 | string container, | 169 | } |
170 | StatVerbosity verbosity) | 170 | } |
171 | : base(shortName, name, description, unitName, category, container, StatType.Push, null, verbosity) | 171 | } |
172 | { | 172 | |
173 | m_histograms = new SortedDictionary<string, EventHistogram>(); | 173 | // A statistic that wraps a counter. |
174 | } | 174 | // Built this way mostly so histograms and history can be created. |
175 | 175 | public class CounterStat : Stat | |
176 | // Histograms are presumably added at intialization time and the list does not change thereafter. | 176 | { |
177 | // Thus no locking of the histogram list. | 177 | private SortedDictionary<string, EventHistogram> m_histograms; |
178 | public void AddHistogram(string histoName, EventHistogram histo) | 178 | private object counterLock = new object(); |
179 | { | 179 | |
180 | m_histograms.Add(histoName, histo); | 180 | public CounterStat( |
181 | } | 181 | string shortName, |
182 | 182 | string name, | |
183 | public delegate void ProcessHistogram(string name, EventHistogram histo); | 183 | string description, |
184 | public void ForEachHistogram(ProcessHistogram process) | 184 | string unitName, |
185 | { | 185 | string category, |
186 | foreach (KeyValuePair<string, EventHistogram> kvp in m_histograms) | 186 | string container, |
187 | { | 187 | StatVerbosity verbosity) |
188 | process(kvp.Key, kvp.Value); | 188 | : base(shortName, name, description, unitName, category, container, StatType.Push, null, verbosity) |
189 | } | 189 | { |
190 | } | 190 | m_histograms = new SortedDictionary<string, EventHistogram>(); |
191 | 191 | } | |
192 | public void Event() | 192 | |
193 | { | 193 | // Histograms are presumably added at intialization time and the list does not change thereafter. |
194 | this.Event(1); | 194 | // Thus no locking of the histogram list. |
195 | } | 195 | public void AddHistogram(string histoName, EventHistogram histo) |
196 | 196 | { | |
197 | // Count the underlying counter. | 197 | m_histograms.Add(histoName, histo); |
198 | public void Event(int cnt) | 198 | } |
199 | { | 199 | |
200 | lock (counterLock) | 200 | public delegate void ProcessHistogram(string name, EventHistogram histo); |
201 | { | 201 | public void ForEachHistogram(ProcessHistogram process) |
202 | base.Value += cnt; | 202 | { |
203 | 203 | foreach (KeyValuePair<string, EventHistogram> kvp in m_histograms) | |
204 | foreach (EventHistogram histo in m_histograms.Values) | 204 | { |
205 | { | 205 | process(kvp.Key, kvp.Value); |
206 | histo.Event(cnt); | 206 | } |
207 | } | 207 | } |
208 | } | 208 | |
209 | } | 209 | public void Event() |
210 | } | 210 | { |
211 | } | 211 | this.Event(1); |
212 | } | ||
213 | |||
214 | // Count the underlying counter. | ||
215 | public void Event(int cnt) | ||
216 | { | ||
217 | lock (counterLock) | ||
218 | { | ||
219 | base.Value += cnt; | ||
220 | |||
221 | foreach (EventHistogram histo in m_histograms.Values) | ||
222 | { | ||
223 | histo.Event(cnt); | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | } | ||
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index c8d9174..2e7665f 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs | |||
@@ -211,7 +211,7 @@ namespace OpenSim.Framework.Monitoring | |||
211 | public virtual string ToConsoleString() | 211 | public virtual string ToConsoleString() |
212 | { | 212 | { |
213 | StringBuilder sb = new StringBuilder(); | 213 | StringBuilder sb = new StringBuilder(); |
214 | sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); | 214 | sb.AppendFormat("{0}.{1}.{2} : {3} {4}", Category, Container, ShortName, Value, UnitName); |
215 | 215 | ||
216 | AppendMeasuresOfInterest(sb); | 216 | AppendMeasuresOfInterest(sb); |
217 | 217 | ||
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 910907e..24db6d4 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -85,6 +85,7 @@ namespace OpenSim.Framework.Monitoring | |||
85 | if (cmd.Length > 2) | 85 | if (cmd.Length > 2) |
86 | { | 86 | { |
87 | var categoryName = cmd[2]; | 87 | var categoryName = cmd[2]; |
88 | var containerName = cmd.Length > 3 ? cmd[3] : String.Empty; | ||
88 | 89 | ||
89 | if (categoryName == AllSubCommand) | 90 | if (categoryName == AllSubCommand) |
90 | { | 91 | { |
@@ -108,7 +109,20 @@ namespace OpenSim.Framework.Monitoring | |||
108 | } | 109 | } |
109 | else | 110 | else |
110 | { | 111 | { |
111 | OutputCategoryStatsToConsole(con, category); | 112 | if (String.IsNullOrEmpty(containerName)) |
113 | OutputCategoryStatsToConsole(con, category); | ||
114 | else | ||
115 | { | ||
116 | SortedDictionary<string, Stat> container; | ||
117 | if (category.TryGetValue(containerName, out container)) | ||
118 | { | ||
119 | OutputContainerStatsToConsole(con, container); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | ||
124 | } | ||
125 | } | ||
112 | } | 126 | } |
113 | } | 127 | } |
114 | } | 128 | } |
@@ -124,10 +138,15 @@ namespace OpenSim.Framework.Monitoring | |||
124 | { | 138 | { |
125 | foreach (var container in category.Values) | 139 | foreach (var container in category.Values) |
126 | { | 140 | { |
127 | foreach (Stat stat in container.Values) | 141 | OutputContainerStatsToConsole(con, container); |
128 | { | 142 | } |
129 | con.Output(stat.ToConsoleString()); | 143 | } |
130 | } | 144 | |
145 | private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) | ||
146 | { | ||
147 | foreach (Stat stat in container.Values) | ||
148 | { | ||
149 | con.Output(stat.ToConsoleString()); | ||
131 | } | 150 | } |
132 | } | 151 | } |
133 | 152 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index aadcdc8..96644ec 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -929,7 +929,25 @@ namespace OpenSim.Framework | |||
929 | /// <returns></returns> | 929 | /// <returns></returns> |
930 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections) | 930 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections) |
931 | { | 931 | { |
932 | object val = default(T); | 932 | return GetConfigVarFromSections<T>(config, varname, sections, default(T)); |
933 | } | ||
934 | |||
935 | /// <summary> | ||
936 | /// Gets the value of a configuration variable by looking into | ||
937 | /// multiple sections in order. The latter sections overwrite | ||
938 | /// any values previously found. | ||
939 | /// </summary> | ||
940 | /// <remarks> | ||
941 | /// If no value is found then the given default value is returned | ||
942 | /// </remarks> | ||
943 | /// <typeparam name="T">Type of the variable</typeparam> | ||
944 | /// <param name="config">The configuration object</param> | ||
945 | /// <param name="varname">The configuration variable</param> | ||
946 | /// <param name="sections">Ordered sequence of sections to look at</param> | ||
947 | /// <param name="val">Default value</param> | ||
948 | /// <returns></returns> | ||
949 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val) | ||
950 | { | ||
933 | foreach (string section in sections) | 951 | foreach (string section in sections) |
934 | { | 952 | { |
935 | IConfig cnf = config.Configs[section]; | 953 | IConfig cnf = config.Configs[section]; |
@@ -937,11 +955,7 @@ namespace OpenSim.Framework | |||
937 | continue; | 955 | continue; |
938 | 956 | ||
939 | if (typeof(T) == typeof(String)) | 957 | if (typeof(T) == typeof(String)) |
940 | { | ||
941 | if (val == null) // no null strings, please | ||
942 | val = string.Empty; | ||
943 | val = cnf.GetString(varname, (string)val); | 958 | val = cnf.GetString(varname, (string)val); |
944 | } | ||
945 | else if (typeof(T) == typeof(Boolean)) | 959 | else if (typeof(T) == typeof(Boolean)) |
946 | val = cnf.GetBoolean(varname, (bool)val); | 960 | val = cnf.GetBoolean(varname, (bool)val); |
947 | else if (typeof(T) == typeof(Int32)) | 961 | else if (typeof(T) == typeof(Int32)) |
@@ -949,8 +963,9 @@ namespace OpenSim.Framework | |||
949 | else if (typeof(T) == typeof(float)) | 963 | else if (typeof(T) == typeof(float)) |
950 | val = cnf.GetFloat(varname, (int)val); | 964 | val = cnf.GetFloat(varname, (int)val); |
951 | else | 965 | else |
952 | m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T)); | 966 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); |
953 | } | 967 | } |
968 | |||
954 | return (T)val; | 969 | return (T)val; |
955 | } | 970 | } |
956 | 971 | ||