diff options
Diffstat (limited to '')
21 files changed, 1259 insertions, 220 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 16a63e0..dff956a 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console | |||
97 | if (!UUID.TryParse(rawUuid, out uuid)) | 97 | if (!UUID.TryParse(rawUuid, out uuid)) |
98 | { | 98 | { |
99 | if (console != null) | 99 | if (console != null) |
100 | console.OutputFormat("{0} is not a valid uuid", rawUuid); | 100 | console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); |
101 | 101 | ||
102 | return false; | 102 | return false; |
103 | } | 103 | } |
@@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console | |||
110 | if (!uint.TryParse(rawLocalId, out localId)) | 110 | if (!uint.TryParse(rawLocalId, out localId)) |
111 | { | 111 | { |
112 | if (console != null) | 112 | if (console != null) |
113 | console.OutputFormat("{0} is not a valid local id", localId); | 113 | console.OutputFormat("ERROR: {0} is not a valid local id", localId); |
114 | 114 | ||
115 | return false; | 115 | return false; |
116 | } | 116 | } |
@@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console | |||
118 | if (localId == 0) | 118 | if (localId == 0) |
119 | { | 119 | { |
120 | if (console != null) | 120 | if (console != null) |
121 | console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId); | 121 | console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); |
122 | 122 | ||
123 | return false; | 123 | return false; |
124 | } | 124 | } |
@@ -150,10 +150,30 @@ namespace OpenSim.Framework.Console | |||
150 | } | 150 | } |
151 | 151 | ||
152 | if (console != null) | 152 | if (console != null) |
153 | console.OutputFormat("{0} is not a valid UUID or local id", rawId); | 153 | console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); |
154 | 154 | ||
155 | return false; | 155 | return false; |
156 | } | 156 | } |
157 | |||
158 | /// <summary> | ||
159 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | ||
160 | /// </summary> | ||
161 | /// <param name='console'>Can be null if no console is available.</param> | ||
162 | /// <param name='rawConsoleVector'>/param> | ||
163 | /// <param name='vector'></param> | ||
164 | /// <returns></returns> | ||
165 | public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) | ||
166 | { | ||
167 | if (!int.TryParse(rawConsoleInt, out i)) | ||
168 | { | ||
169 | if (console != null) | ||
170 | console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); | ||
171 | |||
172 | return false; | ||
173 | } | ||
174 | |||
175 | return true; | ||
176 | } | ||
157 | 177 | ||
158 | /// <summary> | 178 | /// <summary> |
159 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | 179 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 |
diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs new file mode 100644 index 0000000..9056548 --- /dev/null +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | |||
@@ -0,0 +1,508 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008, openmetaverse.org, http://opensimulator.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * - Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * - Redistributions of source code must retain the above copyright notice, this | ||
9 | * list of conditions and the following disclaimer. | ||
10 | * - Neither the name of the openmetaverse.org nor the names | ||
11 | * of its contributors may be used to endorse or promote products derived from | ||
12 | * this software without specific prior written permission. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
24 | * POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | using System; | ||
28 | using System.Threading; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// A double dictionary that is thread abort safe. | ||
35 | /// </summary> | ||
36 | /// <remarks> | ||
37 | /// This adapts OpenMetaverse.DoubleDictionary to be thread-abort safe by acquiring ReaderWriterLockSlim within | ||
38 | /// a finally section (which can't be interrupted by Thread.Abort()). | ||
39 | /// </remarks> | ||
40 | public class DoubleDictionaryThreadAbortSafe<TKey1, TKey2, TValue> | ||
41 | { | ||
42 | Dictionary<TKey1, TValue> Dictionary1; | ||
43 | Dictionary<TKey2, TValue> Dictionary2; | ||
44 | ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(); | ||
45 | |||
46 | public DoubleDictionaryThreadAbortSafe() | ||
47 | { | ||
48 | Dictionary1 = new Dictionary<TKey1,TValue>(); | ||
49 | Dictionary2 = new Dictionary<TKey2,TValue>(); | ||
50 | } | ||
51 | |||
52 | public DoubleDictionaryThreadAbortSafe(int capacity) | ||
53 | { | ||
54 | Dictionary1 = new Dictionary<TKey1, TValue>(capacity); | ||
55 | Dictionary2 = new Dictionary<TKey2, TValue>(capacity); | ||
56 | } | ||
57 | |||
58 | public void Add(TKey1 key1, TKey2 key2, TValue value) | ||
59 | { | ||
60 | bool gotLock = false; | ||
61 | |||
62 | try | ||
63 | { | ||
64 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
65 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
66 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
67 | try {} | ||
68 | finally | ||
69 | { | ||
70 | rwLock.EnterWriteLock(); | ||
71 | gotLock = true; | ||
72 | } | ||
73 | |||
74 | if (Dictionary1.ContainsKey(key1)) | ||
75 | { | ||
76 | if (!Dictionary2.ContainsKey(key2)) | ||
77 | throw new ArgumentException("key1 exists in the dictionary but not key2"); | ||
78 | } | ||
79 | else if (Dictionary2.ContainsKey(key2)) | ||
80 | { | ||
81 | if (!Dictionary1.ContainsKey(key1)) | ||
82 | throw new ArgumentException("key2 exists in the dictionary but not key1"); | ||
83 | } | ||
84 | |||
85 | Dictionary1[key1] = value; | ||
86 | Dictionary2[key2] = value; | ||
87 | } | ||
88 | finally | ||
89 | { | ||
90 | if (gotLock) | ||
91 | rwLock.ExitWriteLock(); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public bool Remove(TKey1 key1, TKey2 key2) | ||
96 | { | ||
97 | bool success; | ||
98 | bool gotLock = false; | ||
99 | |||
100 | try | ||
101 | { | ||
102 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
103 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
104 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
105 | try {} | ||
106 | finally | ||
107 | { | ||
108 | rwLock.EnterWriteLock(); | ||
109 | gotLock = true; | ||
110 | } | ||
111 | |||
112 | Dictionary1.Remove(key1); | ||
113 | success = Dictionary2.Remove(key2); | ||
114 | } | ||
115 | finally | ||
116 | { | ||
117 | if (gotLock) | ||
118 | rwLock.ExitWriteLock(); | ||
119 | } | ||
120 | |||
121 | return success; | ||
122 | } | ||
123 | |||
124 | public bool Remove(TKey1 key1) | ||
125 | { | ||
126 | bool found = false; | ||
127 | bool gotLock = false; | ||
128 | |||
129 | try | ||
130 | { | ||
131 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
132 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
133 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
134 | try {} | ||
135 | finally | ||
136 | { | ||
137 | rwLock.EnterWriteLock(); | ||
138 | gotLock = true; | ||
139 | } | ||
140 | |||
141 | // This is an O(n) operation! | ||
142 | TValue value; | ||
143 | if (Dictionary1.TryGetValue(key1, out value)) | ||
144 | { | ||
145 | foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2) | ||
146 | { | ||
147 | if (kvp.Value.Equals(value)) | ||
148 | { | ||
149 | Dictionary1.Remove(key1); | ||
150 | Dictionary2.Remove(kvp.Key); | ||
151 | found = true; | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | finally | ||
158 | { | ||
159 | if (gotLock) | ||
160 | rwLock.ExitWriteLock(); | ||
161 | } | ||
162 | |||
163 | return found; | ||
164 | } | ||
165 | |||
166 | public bool Remove(TKey2 key2) | ||
167 | { | ||
168 | bool found = false; | ||
169 | bool gotLock = false; | ||
170 | |||
171 | try | ||
172 | { | ||
173 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
174 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
175 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
176 | try {} | ||
177 | finally | ||
178 | { | ||
179 | rwLock.EnterWriteLock(); | ||
180 | gotLock = true; | ||
181 | } | ||
182 | |||
183 | // This is an O(n) operation! | ||
184 | TValue value; | ||
185 | if (Dictionary2.TryGetValue(key2, out value)) | ||
186 | { | ||
187 | foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1) | ||
188 | { | ||
189 | if (kvp.Value.Equals(value)) | ||
190 | { | ||
191 | Dictionary2.Remove(key2); | ||
192 | Dictionary1.Remove(kvp.Key); | ||
193 | found = true; | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | finally | ||
200 | { | ||
201 | if (gotLock) | ||
202 | rwLock.ExitWriteLock(); | ||
203 | } | ||
204 | |||
205 | return found; | ||
206 | } | ||
207 | |||
208 | public void Clear() | ||
209 | { | ||
210 | bool gotLock = false; | ||
211 | |||
212 | try | ||
213 | { | ||
214 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
215 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
216 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
217 | try {} | ||
218 | finally | ||
219 | { | ||
220 | rwLock.EnterWriteLock(); | ||
221 | gotLock = true; | ||
222 | } | ||
223 | |||
224 | Dictionary1.Clear(); | ||
225 | Dictionary2.Clear(); | ||
226 | } | ||
227 | finally | ||
228 | { | ||
229 | if (gotLock) | ||
230 | rwLock.ExitWriteLock(); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | public int Count | ||
235 | { | ||
236 | get { return Dictionary1.Count; } | ||
237 | } | ||
238 | |||
239 | public bool ContainsKey(TKey1 key) | ||
240 | { | ||
241 | return Dictionary1.ContainsKey(key); | ||
242 | } | ||
243 | |||
244 | public bool ContainsKey(TKey2 key) | ||
245 | { | ||
246 | return Dictionary2.ContainsKey(key); | ||
247 | } | ||
248 | |||
249 | public bool TryGetValue(TKey1 key, out TValue value) | ||
250 | { | ||
251 | bool success; | ||
252 | bool gotLock = false; | ||
253 | |||
254 | try | ||
255 | { | ||
256 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
257 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
258 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
259 | try {} | ||
260 | finally | ||
261 | { | ||
262 | rwLock.EnterReadLock(); | ||
263 | gotLock = true; | ||
264 | } | ||
265 | |||
266 | success = Dictionary1.TryGetValue(key, out value); | ||
267 | } | ||
268 | finally | ||
269 | { | ||
270 | if (gotLock) | ||
271 | rwLock.ExitReadLock(); | ||
272 | } | ||
273 | |||
274 | return success; | ||
275 | } | ||
276 | |||
277 | public bool TryGetValue(TKey2 key, out TValue value) | ||
278 | { | ||
279 | bool success; | ||
280 | bool gotLock = false; | ||
281 | |||
282 | try | ||
283 | { | ||
284 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
285 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
286 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
287 | try {} | ||
288 | finally | ||
289 | { | ||
290 | rwLock.EnterReadLock(); | ||
291 | gotLock = true; | ||
292 | } | ||
293 | |||
294 | success = Dictionary2.TryGetValue(key, out value); | ||
295 | } | ||
296 | finally | ||
297 | { | ||
298 | if (gotLock) | ||
299 | rwLock.ExitReadLock(); | ||
300 | } | ||
301 | |||
302 | return success; | ||
303 | } | ||
304 | |||
305 | public void ForEach(Action<TValue> action) | ||
306 | { | ||
307 | bool gotLock = false; | ||
308 | |||
309 | try | ||
310 | { | ||
311 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
312 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
313 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
314 | try {} | ||
315 | finally | ||
316 | { | ||
317 | rwLock.EnterReadLock(); | ||
318 | gotLock = true; | ||
319 | } | ||
320 | |||
321 | foreach (TValue value in Dictionary1.Values) | ||
322 | action(value); | ||
323 | } | ||
324 | finally | ||
325 | { | ||
326 | if (gotLock) | ||
327 | rwLock.ExitReadLock(); | ||
328 | } | ||
329 | } | ||
330 | |||
331 | public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) | ||
332 | { | ||
333 | bool gotLock = false; | ||
334 | |||
335 | try | ||
336 | { | ||
337 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
338 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
339 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
340 | try {} | ||
341 | finally | ||
342 | { | ||
343 | rwLock.EnterReadLock(); | ||
344 | gotLock = true; | ||
345 | } | ||
346 | |||
347 | foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1) | ||
348 | action(entry); | ||
349 | } | ||
350 | finally | ||
351 | { | ||
352 | if (gotLock) | ||
353 | rwLock.ExitReadLock(); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | public void ForEach(Action<KeyValuePair<TKey2, TValue>> action) | ||
358 | { | ||
359 | bool gotLock = false; | ||
360 | |||
361 | try | ||
362 | { | ||
363 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
364 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
365 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
366 | try {} | ||
367 | finally | ||
368 | { | ||
369 | rwLock.EnterReadLock(); | ||
370 | gotLock = true; | ||
371 | } | ||
372 | |||
373 | foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2) | ||
374 | action(entry); | ||
375 | } | ||
376 | finally | ||
377 | { | ||
378 | if (gotLock) | ||
379 | rwLock.ExitReadLock(); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | public TValue FindValue(Predicate<TValue> predicate) | ||
384 | { | ||
385 | bool gotLock = false; | ||
386 | |||
387 | try | ||
388 | { | ||
389 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
390 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
391 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
392 | try {} | ||
393 | finally | ||
394 | { | ||
395 | rwLock.EnterReadLock(); | ||
396 | gotLock = true; | ||
397 | } | ||
398 | |||
399 | foreach (TValue value in Dictionary1.Values) | ||
400 | { | ||
401 | if (predicate(value)) | ||
402 | return value; | ||
403 | } | ||
404 | } | ||
405 | finally | ||
406 | { | ||
407 | if (gotLock) | ||
408 | rwLock.ExitReadLock(); | ||
409 | } | ||
410 | |||
411 | return default(TValue); | ||
412 | } | ||
413 | |||
414 | public IList<TValue> FindAll(Predicate<TValue> predicate) | ||
415 | { | ||
416 | IList<TValue> list = new List<TValue>(); | ||
417 | bool gotLock = false; | ||
418 | |||
419 | try | ||
420 | { | ||
421 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
422 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
423 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
424 | try {} | ||
425 | finally | ||
426 | { | ||
427 | rwLock.EnterReadLock(); | ||
428 | gotLock = true; | ||
429 | } | ||
430 | |||
431 | foreach (TValue value in Dictionary1.Values) | ||
432 | { | ||
433 | if (predicate(value)) | ||
434 | list.Add(value); | ||
435 | } | ||
436 | } | ||
437 | finally | ||
438 | { | ||
439 | if (gotLock) | ||
440 | rwLock.ExitReadLock(); | ||
441 | } | ||
442 | |||
443 | return list; | ||
444 | } | ||
445 | |||
446 | public int RemoveAll(Predicate<TValue> predicate) | ||
447 | { | ||
448 | IList<TKey1> list = new List<TKey1>(); | ||
449 | bool gotUpgradeableLock = false; | ||
450 | |||
451 | try | ||
452 | { | ||
453 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
454 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
455 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
456 | try {} | ||
457 | finally | ||
458 | { | ||
459 | rwLock.EnterUpgradeableReadLock(); | ||
460 | gotUpgradeableLock = true; | ||
461 | } | ||
462 | |||
463 | foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1) | ||
464 | { | ||
465 | if (predicate(kvp.Value)) | ||
466 | list.Add(kvp.Key); | ||
467 | } | ||
468 | |||
469 | IList<TKey2> list2 = new List<TKey2>(list.Count); | ||
470 | foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2) | ||
471 | { | ||
472 | if (predicate(kvp.Value)) | ||
473 | list2.Add(kvp.Key); | ||
474 | } | ||
475 | |||
476 | bool gotWriteLock = false; | ||
477 | |||
478 | try | ||
479 | { | ||
480 | try {} | ||
481 | finally | ||
482 | { | ||
483 | rwLock.EnterUpgradeableReadLock(); | ||
484 | gotWriteLock = true; | ||
485 | } | ||
486 | |||
487 | for (int i = 0; i < list.Count; i++) | ||
488 | Dictionary1.Remove(list[i]); | ||
489 | |||
490 | for (int i = 0; i < list2.Count; i++) | ||
491 | Dictionary2.Remove(list2[i]); | ||
492 | } | ||
493 | finally | ||
494 | { | ||
495 | if (gotWriteLock) | ||
496 | rwLock.ExitWriteLock(); | ||
497 | } | ||
498 | } | ||
499 | finally | ||
500 | { | ||
501 | if (gotUpgradeableLock) | ||
502 | rwLock.ExitUpgradeableReadLock(); | ||
503 | } | ||
504 | |||
505 | return list.Count; | ||
506 | } | ||
507 | } | ||
508 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/PluginManager.cs b/OpenSim/Framework/PluginManager.cs new file mode 100644 index 0000000..00263f5 --- /dev/null +++ b/OpenSim/Framework/PluginManager.cs | |||
@@ -0,0 +1,563 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
4 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the OpenSimulator Project nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
20 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
28 | |||
29 | |||
30 | using System; | ||
31 | using System.Text; | ||
32 | using System.Linq; | ||
33 | using System.Collections; | ||
34 | using System.Collections.Generic; | ||
35 | using System.Collections.ObjectModel; | ||
36 | using Mono.Addins; | ||
37 | using Mono.Addins.Setup; | ||
38 | using Mono.Addins.Description; | ||
39 | using OpenSim.Framework; | ||
40 | |||
41 | |||
42 | namespace OpenSim.Framework | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Manager for registries and plugins | ||
46 | /// </summary> | ||
47 | public class PluginManager : SetupService | ||
48 | { | ||
49 | public AddinRegistry PluginRegistry; | ||
50 | |||
51 | public PluginManager(AddinRegistry registry): base (registry) | ||
52 | { | ||
53 | PluginRegistry = registry; | ||
54 | |||
55 | } | ||
56 | |||
57 | /// <summary> | ||
58 | /// Installs the plugin. | ||
59 | /// </summary> | ||
60 | /// <returns> | ||
61 | /// The plugin. | ||
62 | /// </returns> | ||
63 | /// <param name='args'> | ||
64 | /// Arguments. | ||
65 | /// </param> | ||
66 | public bool InstallPlugin(int ndx, out Dictionary<string, object> result) | ||
67 | { | ||
68 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
69 | |||
70 | PackageCollection pack = new PackageCollection(); | ||
71 | PackageCollection toUninstall; | ||
72 | DependencyCollection unresolved; | ||
73 | |||
74 | IProgressStatus ps = new ConsoleProgressStatus(false); | ||
75 | |||
76 | AddinRepositoryEntry[] available = GetSortedAvailbleAddins(); | ||
77 | |||
78 | if (ndx > (available.Length - 1)) | ||
79 | { | ||
80 | MainConsole.Instance.Output("Selection out of range"); | ||
81 | result = res; | ||
82 | return false; | ||
83 | } | ||
84 | |||
85 | AddinRepositoryEntry aentry = available[ndx]; | ||
86 | |||
87 | Package p = Package.FromRepository(aentry); | ||
88 | pack.Add(p); | ||
89 | |||
90 | ResolveDependencies(ps, pack, out toUninstall, out unresolved); | ||
91 | |||
92 | // Attempt to install the plugin disabled | ||
93 | if (Install(ps, pack) == true) | ||
94 | { | ||
95 | MainConsole.Instance.Output("Ignore the following error..."); | ||
96 | PluginRegistry.Update(ps); | ||
97 | Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id); | ||
98 | PluginRegistry.DisableAddin(addin.Id); | ||
99 | addin.Enabled = false; | ||
100 | |||
101 | MainConsole.Instance.Output("Installation Success"); | ||
102 | ListInstalledAddins(out res); | ||
103 | result = res; | ||
104 | return true; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | MainConsole.Instance.Output("Installation Failed"); | ||
109 | result = res; | ||
110 | return false; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | // Remove plugin | ||
115 | /// <summary> | ||
116 | /// Uns the install. | ||
117 | /// </summary> | ||
118 | /// <param name='args'> | ||
119 | /// Arguments. | ||
120 | /// </param> | ||
121 | public void UnInstall(int ndx) | ||
122 | { | ||
123 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
124 | |||
125 | if (ndx > (addins.Length -1)) | ||
126 | { | ||
127 | MainConsole.Instance.Output("Selection out of range"); | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | Addin addin = addins[ndx]; | ||
132 | MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id); | ||
133 | AddinManager.Registry.DisableAddin(addin.Id); | ||
134 | addin.Enabled = false; | ||
135 | IProgressStatus ps = new ConsoleProgressStatus(false); | ||
136 | Uninstall(ps, addin.Id); | ||
137 | MainConsole.Instance.Output("Uninstall Success - restart to complete operation"); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Checks the installed. | ||
143 | /// </summary> | ||
144 | /// <returns> | ||
145 | /// The installed. | ||
146 | /// </returns> | ||
147 | public string CheckInstalled() | ||
148 | { | ||
149 | return "CheckInstall"; | ||
150 | } | ||
151 | |||
152 | /// <summary> | ||
153 | /// Lists the installed addins. | ||
154 | /// </summary> | ||
155 | /// <param name='result'> | ||
156 | /// Result. | ||
157 | /// </param> | ||
158 | public void ListInstalledAddins(out Dictionary<string, object> result) | ||
159 | { | ||
160 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
161 | |||
162 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
163 | if(addins.Count() < 1) | ||
164 | { | ||
165 | MainConsole.Instance.Output("Error!"); | ||
166 | } | ||
167 | int count = 0; | ||
168 | foreach (Addin addin in addins) | ||
169 | { | ||
170 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
171 | r["enabled"] = addin.Enabled == true ? true : false; | ||
172 | r["name"] = addin.LocalId; | ||
173 | r["version"] = addin.Version; | ||
174 | |||
175 | res.Add(count.ToString(), r); | ||
176 | |||
177 | count++; | ||
178 | } | ||
179 | result = res; | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | // List compatible plugins in registered repositories | ||
184 | /// <summary> | ||
185 | /// Lists the available. | ||
186 | /// </summary> | ||
187 | /// <param name='result'> | ||
188 | /// Result. | ||
189 | /// </param> | ||
190 | public void ListAvailable(out Dictionary<string, object> result) | ||
191 | { | ||
192 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
193 | |||
194 | AddinRepositoryEntry[] addins = GetSortedAvailbleAddins(); | ||
195 | |||
196 | int count = 0; | ||
197 | foreach (AddinRepositoryEntry addin in addins) | ||
198 | { | ||
199 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
200 | r["name"] = addin.Addin.Name; | ||
201 | r["version"] = addin.Addin.Version; | ||
202 | r["repository"] = addin.RepositoryName; | ||
203 | |||
204 | res.Add(count.ToString(), r); | ||
205 | count++; | ||
206 | } | ||
207 | result = res; | ||
208 | return; | ||
209 | } | ||
210 | |||
211 | // List available updates ** 1 | ||
212 | /// <summary> | ||
213 | /// Lists the updates. | ||
214 | /// </summary> | ||
215 | public void ListUpdates() | ||
216 | { | ||
217 | IProgressStatus ps = new ConsoleProgressStatus(true); | ||
218 | Console.WriteLine ("Looking for updates..."); | ||
219 | Repositories.UpdateAllRepositories (ps); | ||
220 | Console.WriteLine ("Available add-in updates:"); | ||
221 | bool found = false; | ||
222 | AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates(); | ||
223 | |||
224 | foreach (AddinRepositoryEntry entry in entries) | ||
225 | { | ||
226 | Console.WriteLine(String.Format("{0}",entry.Addin.Id)); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | // Sync to repositories | ||
231 | /// <summary> | ||
232 | /// Update this instance. | ||
233 | /// </summary> | ||
234 | public string Update() | ||
235 | { | ||
236 | IProgressStatus ps = new ConsoleProgressStatus(true); | ||
237 | Repositories.UpdateAllRepositories(ps); | ||
238 | return "Update"; | ||
239 | } | ||
240 | |||
241 | // Register a repository | ||
242 | /// <summary> | ||
243 | /// Register a repository with our server. | ||
244 | /// </summary> | ||
245 | /// <returns> | ||
246 | /// result of the action | ||
247 | /// </returns> | ||
248 | /// <param name='repo'> | ||
249 | /// The URL of the repository we want to add | ||
250 | /// </param> | ||
251 | public bool AddRepository(string repo) | ||
252 | { | ||
253 | Repositories.RegisterRepository(null, repo, true); | ||
254 | PluginRegistry.Rebuild(null); | ||
255 | |||
256 | return true; | ||
257 | } | ||
258 | |||
259 | /// <summary> | ||
260 | /// Gets the repository. | ||
261 | /// </summary> | ||
262 | public void GetRepository() | ||
263 | { | ||
264 | Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false)); | ||
265 | } | ||
266 | |||
267 | // Remove a repository from the list | ||
268 | /// <summary> | ||
269 | /// Removes the repository. | ||
270 | /// </summary> | ||
271 | /// <param name='args'> | ||
272 | /// Arguments. | ||
273 | /// </param> | ||
274 | public void RemoveRepository(string[] args) | ||
275 | { | ||
276 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
277 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
278 | if (reps.Length == 0) | ||
279 | { | ||
280 | MainConsole.Instance.Output("No repositories have been registered."); | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | int n = Convert.ToInt16(args[2]); | ||
285 | if (n > (reps.Length -1)) | ||
286 | { | ||
287 | MainConsole.Instance.Output("Selection out of range"); | ||
288 | return; | ||
289 | } | ||
290 | |||
291 | AddinRepository rep = reps[n]; | ||
292 | Repositories.RemoveRepository(rep.Url); | ||
293 | return; | ||
294 | } | ||
295 | |||
296 | // Enable repository | ||
297 | /// <summary> | ||
298 | /// Enables the repository. | ||
299 | /// </summary> | ||
300 | /// <param name='args'> | ||
301 | /// Arguments. | ||
302 | /// </param> | ||
303 | public void EnableRepository(string[] args) | ||
304 | { | ||
305 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
306 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
307 | if (reps.Length == 0) | ||
308 | { | ||
309 | MainConsole.Instance.Output("No repositories have been registered."); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | int n = Convert.ToInt16(args[2]); | ||
314 | if (n > (reps.Length -1)) | ||
315 | { | ||
316 | MainConsole.Instance.Output("Selection out of range"); | ||
317 | return; | ||
318 | } | ||
319 | |||
320 | AddinRepository rep = reps[n]; | ||
321 | Repositories.SetRepositoryEnabled(rep.Url, true); | ||
322 | return; | ||
323 | } | ||
324 | |||
325 | // Disable a repository | ||
326 | /// <summary> | ||
327 | /// Disables the repository. | ||
328 | /// </summary> | ||
329 | /// <param name='args'> | ||
330 | /// Arguments. | ||
331 | /// </param> | ||
332 | public void DisableRepository(string[] args) | ||
333 | { | ||
334 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
335 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
336 | if (reps.Length == 0) | ||
337 | { | ||
338 | MainConsole.Instance.Output("No repositories have been registered."); | ||
339 | return; | ||
340 | } | ||
341 | |||
342 | int n = Convert.ToInt16(args[2]); | ||
343 | if (n > (reps.Length -1)) | ||
344 | { | ||
345 | MainConsole.Instance.Output("Selection out of range"); | ||
346 | return; | ||
347 | } | ||
348 | |||
349 | AddinRepository rep = reps[n]; | ||
350 | Repositories.SetRepositoryEnabled(rep.Url, false); | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | // List registered repositories | ||
355 | /// <summary> | ||
356 | /// Lists the repositories. | ||
357 | /// </summary> | ||
358 | /// <param name='result'> | ||
359 | /// Result. | ||
360 | /// </param> | ||
361 | public void ListRepositories(out Dictionary<string, object> result) | ||
362 | { | ||
363 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
364 | result = res; | ||
365 | |||
366 | AddinRepository[] reps = GetSortedAddinRepo(); | ||
367 | if (reps.Length == 0) | ||
368 | { | ||
369 | MainConsole.Instance.Output("No repositories have been registered."); | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | int count = 0; | ||
374 | foreach (AddinRepository rep in reps) | ||
375 | { | ||
376 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
377 | r["enabled"] = rep.Enabled == true ? true : false; | ||
378 | r["name"] = rep.Name; | ||
379 | r["url"] = rep.Url; | ||
380 | |||
381 | res.Add(count.ToString(), r); | ||
382 | count++; | ||
383 | } | ||
384 | return; | ||
385 | } | ||
386 | |||
387 | /// <summary> | ||
388 | /// Updates the registry. | ||
389 | /// </summary> | ||
390 | public void UpdateRegistry() | ||
391 | { | ||
392 | PluginRegistry.Update(); | ||
393 | } | ||
394 | |||
395 | // Show plugin info | ||
396 | /// <summary> | ||
397 | /// Addins the info. | ||
398 | /// </summary> | ||
399 | /// <returns> | ||
400 | /// The info. | ||
401 | /// </returns> | ||
402 | /// <param name='args'> | ||
403 | /// Arguments. | ||
404 | /// </param> | ||
405 | public bool AddinInfo(int ndx, out Dictionary<string, object> result) | ||
406 | { | ||
407 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
408 | result = res; | ||
409 | |||
410 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
411 | |||
412 | if (ndx > (addins.Length - 1)) | ||
413 | { | ||
414 | MainConsole.Instance.Output("Selection out of range"); | ||
415 | return false; | ||
416 | } | ||
417 | // author category description | ||
418 | Addin addin = addins[ndx]; | ||
419 | |||
420 | res["author"] = addin.Description.Author; | ||
421 | res["category"] = addin.Description.Category; | ||
422 | res["description"] = addin.Description.Description; | ||
423 | res["name"] = addin.Name; | ||
424 | res["url"] = addin.Description.Url; | ||
425 | res["file_name"] = addin.Description.FileName; | ||
426 | |||
427 | result = res; | ||
428 | return true; | ||
429 | } | ||
430 | |||
431 | // Disable a plugin | ||
432 | /// <summary> | ||
433 | /// Disables the plugin. | ||
434 | /// </summary> | ||
435 | /// <param name='args'> | ||
436 | /// Arguments. | ||
437 | /// </param> | ||
438 | public void DisablePlugin(string[] args) | ||
439 | { | ||
440 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
441 | |||
442 | int n = Convert.ToInt16(args[2]); | ||
443 | if (n > (addins.Length -1)) | ||
444 | { | ||
445 | MainConsole.Instance.Output("Selection out of range"); | ||
446 | return; | ||
447 | } | ||
448 | |||
449 | Addin addin = addins[n]; | ||
450 | AddinManager.Registry.DisableAddin(addin.Id); | ||
451 | addin.Enabled = false; | ||
452 | return; | ||
453 | } | ||
454 | |||
455 | // Enable plugin | ||
456 | /// <summary> | ||
457 | /// Enables the plugin. | ||
458 | /// </summary> | ||
459 | /// <param name='args'> | ||
460 | /// Arguments. | ||
461 | /// </param> | ||
462 | public void EnablePlugin(string[] args) | ||
463 | { | ||
464 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
465 | |||
466 | int n = Convert.ToInt16(args[2]); | ||
467 | if (n > (addins.Length -1)) | ||
468 | { | ||
469 | MainConsole.Instance.Output("Selection out of range"); | ||
470 | return; | ||
471 | } | ||
472 | |||
473 | Addin addin = addins[n]; | ||
474 | |||
475 | addin.Enabled = true; | ||
476 | AddinManager.Registry.EnableAddin(addin.Id); | ||
477 | // AddinManager.Registry.Update(); | ||
478 | if(PluginRegistry.IsAddinEnabled(addin.Id)) | ||
479 | { | ||
480 | ConsoleProgressStatus ps = new ConsoleProgressStatus(false); | ||
481 | if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id)) | ||
482 | { | ||
483 | MainConsole.Instance.Output("Ignore the following error..."); | ||
484 | AddinManager.Registry.Rebuild(ps); | ||
485 | AddinManager.AddinEngine.LoadAddin(ps, addin.Id); | ||
486 | } | ||
487 | } | ||
488 | else | ||
489 | { | ||
490 | MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name); | ||
491 | } | ||
492 | return; | ||
493 | } | ||
494 | |||
495 | |||
496 | |||
497 | #region Util | ||
498 | private void Testing() | ||
499 | { | ||
500 | Addin[] list = Registry.GetAddins(); | ||
501 | |||
502 | var addins = list.Where( a => a.Description.Category == "RobustPlugin"); | ||
503 | |||
504 | foreach (Addin addin in addins) | ||
505 | { | ||
506 | MainConsole.Instance.OutputFormat("Addin {0}", addin.Name); | ||
507 | } | ||
508 | } | ||
509 | |||
510 | // These will let us deal with numbered lists instead | ||
511 | // of needing to type in the full ids | ||
512 | private AddinRepositoryEntry[] GetSortedAvailbleAddins() | ||
513 | { | ||
514 | ArrayList list = new ArrayList(); | ||
515 | list.AddRange(Repositories.GetAvailableAddins()); | ||
516 | |||
517 | AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[]; | ||
518 | |||
519 | Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id)); | ||
520 | |||
521 | return addins; | ||
522 | } | ||
523 | |||
524 | private AddinRepository[] GetSortedAddinRepo() | ||
525 | { | ||
526 | ArrayList list = new ArrayList(); | ||
527 | list.AddRange(Repositories.GetRepositories()); | ||
528 | |||
529 | AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[]; | ||
530 | Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name)); | ||
531 | |||
532 | return repos; | ||
533 | } | ||
534 | |||
535 | private Addin[] GetSortedAddinList(string category) | ||
536 | { | ||
537 | |||
538 | ArrayList xlist = new ArrayList(); | ||
539 | ArrayList list = new ArrayList(); | ||
540 | try | ||
541 | { | ||
542 | list.AddRange(PluginRegistry.GetAddins()); | ||
543 | } | ||
544 | catch(Exception e) | ||
545 | { | ||
546 | Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[]; | ||
547 | return x; | ||
548 | } | ||
549 | |||
550 | foreach (Addin addin in list) | ||
551 | { | ||
552 | if (addin.Description.Category == category) | ||
553 | xlist.Add(addin); | ||
554 | } | ||
555 | |||
556 | Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[]; | ||
557 | Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id)); | ||
558 | |||
559 | return addins; | ||
560 | } | ||
561 | #endregion Util | ||
562 | } | ||
563 | } | ||
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index fcc9873..948c259 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -192,18 +192,7 @@ namespace OpenSim.Framework | |||
192 | 192 | ||
193 | public PrimitiveBaseShape() | 193 | public PrimitiveBaseShape() |
194 | { | 194 | { |
195 | PCode = (byte) PCodeEnum.Primitive; | ||
196 | ExtraParams = new byte[1]; | ||
197 | m_textureEntry = DEFAULT_TEXTURE; | ||
198 | } | ||
199 | |||
200 | public PrimitiveBaseShape(bool noShape) | ||
201 | { | ||
202 | if (noShape) | ||
203 | return; | ||
204 | |||
205 | PCode = (byte)PCodeEnum.Primitive; | 195 | PCode = (byte)PCodeEnum.Primitive; |
206 | ExtraParams = new byte[1]; | ||
207 | m_textureEntry = DEFAULT_TEXTURE; | 196 | m_textureEntry = DEFAULT_TEXTURE; |
208 | } | 197 | } |
209 | 198 | ||
@@ -216,7 +205,6 @@ namespace OpenSim.Framework | |||
216 | // m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); | 205 | // m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); |
217 | 206 | ||
218 | PCode = (byte)prim.PrimData.PCode; | 207 | PCode = (byte)prim.PrimData.PCode; |
219 | ExtraParams = new byte[1]; | ||
220 | 208 | ||
221 | State = prim.PrimData.State; | 209 | State = prim.PrimData.State; |
222 | PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin); | 210 | PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin); |
@@ -248,7 +236,10 @@ namespace OpenSim.Framework | |||
248 | SculptTexture = prim.Sculpt.SculptTexture; | 236 | SculptTexture = prim.Sculpt.SculptTexture; |
249 | SculptType = (byte)prim.Sculpt.Type; | 237 | SculptType = (byte)prim.Sculpt.Type; |
250 | } | 238 | } |
251 | else SculptType = (byte)OpenMetaverse.SculptType.None; | 239 | else |
240 | { | ||
241 | SculptType = (byte)OpenMetaverse.SculptType.None; | ||
242 | } | ||
252 | } | 243 | } |
253 | 244 | ||
254 | [XmlIgnore] | 245 | [XmlIgnore] |
@@ -340,9 +331,9 @@ namespace OpenSim.Framework | |||
340 | _scale = new Vector3(side, side, side); | 331 | _scale = new Vector3(side, side, side); |
341 | } | 332 | } |
342 | 333 | ||
343 | public void SetHeigth(float heigth) | 334 | public void SetHeigth(float height) |
344 | { | 335 | { |
345 | _scale.Z = heigth; | 336 | _scale.Z = height; |
346 | } | 337 | } |
347 | 338 | ||
348 | public void SetRadius(float radius) | 339 | public void SetRadius(float radius) |
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 48f1c4f..0c12787 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs | |||
@@ -154,6 +154,11 @@ namespace OpenSim.Framework.Serialization | |||
154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; | 154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; |
155 | } | 155 | } |
156 | 156 | ||
157 | public static string CreateOarLandDataPath(LandData ld) | ||
158 | { | ||
159 | return string.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, ld.GlobalID); | ||
160 | } | ||
161 | |||
157 | /// <summary> | 162 | /// <summary> |
158 | /// Create the filename used to store an object in an OpenSim Archive. | 163 | /// Create the filename used to store an object in an OpenSim Archive. |
159 | /// </summary> | 164 | /// </summary> |
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index 8b9756b..ea100ee 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common; | |||
37 | namespace OpenSim.Framework.Serialization.Tests | 37 | namespace OpenSim.Framework.Serialization.Tests |
38 | { | 38 | { |
39 | [TestFixture] | 39 | [TestFixture] |
40 | public class LandDataSerializerTest | 40 | public class LandDataSerializerTest : OpenSimTestCase |
41 | { | 41 | { |
42 | private LandData land; | 42 | private LandData land; |
43 | private LandData landWithParcelAccessList; | 43 | private LandData landWithParcelAccessList; |
diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs index 09b6f6d..142726b 100644 --- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common; | |||
37 | namespace OpenSim.Framework.Serialization.Tests | 37 | namespace OpenSim.Framework.Serialization.Tests |
38 | { | 38 | { |
39 | [TestFixture] | 39 | [TestFixture] |
40 | public class RegionSettingsSerializerTests | 40 | public class RegionSettingsSerializerTests : OpenSimTestCase |
41 | { | 41 | { |
42 | private string m_serializedRs = @"<?xml version=""1.0"" encoding=""utf-16""?> | 42 | private string m_serializedRs = @"<?xml version=""1.0"" encoding=""utf-16""?> |
43 | <RegionSettings> | 43 | <RegionSettings> |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 2c21800..cb47cbf 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
31 | using System.IO; | 30 | using System.IO; |
32 | using System.Reflection; | 31 | using System.Reflection; |
33 | using System.Text; | 32 | using System.Text; |
@@ -99,34 +98,6 @@ namespace OpenSim.Framework.Servers | |||
99 | m_console.Commands.AddCommand("General", false, "shutdown", | 98 | m_console.Commands.AddCommand("General", false, "shutdown", |
100 | "shutdown", | 99 | "shutdown", |
101 | "Quit the application", HandleQuit); | 100 | "Quit the application", HandleQuit); |
102 | |||
103 | m_console.Commands.AddCommand("General", false, "show threads", | ||
104 | "show threads", | ||
105 | "Show thread status", HandleShow); | ||
106 | |||
107 | m_console.Commands.AddCommand("General", false, "show version", | ||
108 | "show version", | ||
109 | "Show server version", HandleShow); | ||
110 | |||
111 | m_console.Commands.AddCommand("General", false, "threads abort", | ||
112 | "threads abort <thread-id>", | ||
113 | "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); | ||
114 | |||
115 | m_console.Commands.AddCommand("General", false, "threads show", | ||
116 | "threads show", | ||
117 | "Show thread status. Synonym for \"show threads\"", | ||
118 | (string module, string[] args) => Notice(GetThreadsReport())); | ||
119 | |||
120 | m_console.Commands.AddCommand("General", false, "force gc", | ||
121 | "force gc", | ||
122 | "Manually invoke runtime garbage collection. For debugging purposes", | ||
123 | HandleForceGc); | ||
124 | } | ||
125 | |||
126 | private void HandleForceGc(string module, string[] args) | ||
127 | { | ||
128 | MainConsole.Instance.Output("Manually invoking runtime garbage collection"); | ||
129 | GC.Collect(); | ||
130 | } | 101 | } |
131 | 102 | ||
132 | /// <summary> | 103 | /// <summary> |
@@ -159,54 +130,6 @@ namespace OpenSim.Framework.Servers | |||
159 | } | 130 | } |
160 | 131 | ||
161 | /// <summary> | 132 | /// <summary> |
162 | /// Get a report about the registered threads in this server. | ||
163 | /// </summary> | ||
164 | protected string GetThreadsReport() | ||
165 | { | ||
166 | // This should be a constant field. | ||
167 | string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}"; | ||
168 | |||
169 | StringBuilder sb = new StringBuilder(); | ||
170 | Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo(); | ||
171 | |||
172 | sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); | ||
173 | |||
174 | int timeNow = Environment.TickCount & Int32.MaxValue; | ||
175 | |||
176 | sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE"); | ||
177 | sb.Append(Environment.NewLine); | ||
178 | |||
179 | foreach (Watchdog.ThreadWatchdogInfo twi in threads) | ||
180 | { | ||
181 | Thread t = twi.Thread; | ||
182 | |||
183 | sb.AppendFormat( | ||
184 | reportFormat, | ||
185 | t.ManagedThreadId, | ||
186 | t.Name, | ||
187 | timeNow - twi.LastTick, | ||
188 | timeNow - twi.FirstTick, | ||
189 | t.Priority, | ||
190 | t.ThreadState); | ||
191 | |||
192 | sb.Append("\n"); | ||
193 | } | ||
194 | |||
195 | sb.Append("\n"); | ||
196 | |||
197 | // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting | ||
198 | // zero active threads. | ||
199 | int totalThreads = Process.GetCurrentProcess().Threads.Count; | ||
200 | if (totalThreads > 0) | ||
201 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); | ||
202 | |||
203 | sb.Append("Main threadpool (excluding script engine pools)\n"); | ||
204 | sb.Append(Util.GetThreadPoolReport()); | ||
205 | |||
206 | return sb.ToString(); | ||
207 | } | ||
208 | |||
209 | /// <summary> | ||
210 | /// Performs initialisation of the scene, such as loading configuration from disk. | 133 | /// Performs initialisation of the scene, such as loading configuration from disk. |
211 | /// </summary> | 134 | /// </summary> |
212 | public virtual void Startup() | 135 | public virtual void Startup() |
@@ -246,50 +169,7 @@ namespace OpenSim.Framework.Servers | |||
246 | private void HandleQuit(string module, string[] args) | 169 | private void HandleQuit(string module, string[] args) |
247 | { | 170 | { |
248 | Shutdown(); | 171 | Shutdown(); |
249 | } | 172 | } |
250 | |||
251 | public override void HandleShow(string module, string[] cmd) | ||
252 | { | ||
253 | base.HandleShow(module, cmd); | ||
254 | |||
255 | List<string> args = new List<string>(cmd); | ||
256 | |||
257 | args.RemoveAt(0); | ||
258 | |||
259 | string[] showParams = args.ToArray(); | ||
260 | |||
261 | switch (showParams[0]) | ||
262 | { | ||
263 | case "threads": | ||
264 | Notice(GetThreadsReport()); | ||
265 | break; | ||
266 | |||
267 | case "version": | ||
268 | Notice(GetVersionText()); | ||
269 | break; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | public virtual void HandleThreadsAbort(string module, string[] cmd) | ||
274 | { | ||
275 | if (cmd.Length != 3) | ||
276 | { | ||
277 | MainConsole.Instance.Output("Usage: threads abort <thread-id>"); | ||
278 | return; | ||
279 | } | ||
280 | |||
281 | int threadId; | ||
282 | if (!int.TryParse(cmd[2], out threadId)) | ||
283 | { | ||
284 | MainConsole.Instance.Output("ERROR: Thread id must be an integer"); | ||
285 | return; | ||
286 | } | ||
287 | |||
288 | if (Watchdog.AbortThread(threadId)) | ||
289 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); | ||
290 | else | ||
291 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); | ||
292 | } | ||
293 | 173 | ||
294 | public string osSecret { | 174 | public string osSecret { |
295 | // Secret uuid for the simulator | 175 | // Secret uuid for the simulator |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 77fce9e..eefcdad 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -437,7 +437,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
437 | // reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); | 437 | // reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); |
438 | //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); | 438 | //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); |
439 | 439 | ||
440 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); | 440 | Culture.SetCurrentCulture(); |
441 | 441 | ||
442 | // // This is the REST agent interface. We require an agent to properly identify | 442 | // // This is the REST agent interface. We require an agent to properly identify |
443 | // // itself. If the REST handler recognizes the prefix it will attempt to | 443 | // // itself. If the REST handler recognizes the prefix it will attempt to |
@@ -1283,59 +1283,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1283 | map["login"] = OSD.FromString("false"); | 1283 | map["login"] = OSD.FromString("false"); |
1284 | return map; | 1284 | return map; |
1285 | } | 1285 | } |
1286 | /// <summary> | ||
1287 | /// A specific agent handler was provided. Such a handler is expecetd to have an | ||
1288 | /// intimate, and highly specific relationship with the client. Consequently, | ||
1289 | /// nothing is done here. | ||
1290 | /// </summary> | ||
1291 | /// <param name="handler"></param> | ||
1292 | /// <param name="request"></param> | ||
1293 | /// <param name="response"></param> | ||
1294 | |||
1295 | private bool HandleAgentRequest(IHttpAgentHandler handler, OSHttpRequest request, OSHttpResponse response) | ||
1296 | { | ||
1297 | // In the case of REST, then handler is responsible for ALL aspects of | ||
1298 | // the request/response handling. Nothing is done here, not even encoding. | ||
1299 | |||
1300 | try | ||
1301 | { | ||
1302 | return handler.Handle(request, response); | ||
1303 | } | ||
1304 | catch (Exception e) | ||
1305 | { | ||
1306 | // If the handler did in fact close the stream, then this will blow | ||
1307 | // chunks. So that that doesn't disturb anybody we throw away any | ||
1308 | // and all exceptions raised. We've done our best to release the | ||
1309 | // client. | ||
1310 | try | ||
1311 | { | ||
1312 | m_log.Warn("[HTTP-AGENT]: Error - " + e.Message); | ||
1313 | response.SendChunked = false; | ||
1314 | response.KeepAlive = true; | ||
1315 | response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError; | ||
1316 | //response.OutputStream.Close(); | ||
1317 | try | ||
1318 | { | ||
1319 | response.Send(); | ||
1320 | //response.FreeContext(); | ||
1321 | } | ||
1322 | catch (SocketException f) | ||
1323 | { | ||
1324 | // This has to be here to prevent a Linux/Mono crash | ||
1325 | m_log.Warn( | ||
1326 | String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", f.Message), f); | ||
1327 | } | ||
1328 | } | ||
1329 | catch(Exception) | ||
1330 | { | ||
1331 | } | ||
1332 | } | ||
1333 | |||
1334 | // Indicate that the request has been "handled" | ||
1335 | |||
1336 | return true; | ||
1337 | |||
1338 | } | ||
1339 | 1286 | ||
1340 | public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) | 1287 | public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) |
1341 | { | 1288 | { |
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index c182a3a..47baac8 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -27,16 +27,19 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using System.Threading; | ||
34 | using log4net; | 36 | using log4net; |
35 | using log4net.Appender; | 37 | using log4net.Appender; |
36 | using log4net.Core; | 38 | using log4net.Core; |
37 | using log4net.Repository; | 39 | using log4net.Repository; |
38 | using Nini.Config; | 40 | using Nini.Config; |
39 | using OpenSim.Framework.Console; | 41 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Monitoring; | ||
40 | 43 | ||
41 | namespace OpenSim.Framework.Servers | 44 | namespace OpenSim.Framework.Servers |
42 | { | 45 | { |
@@ -168,6 +171,9 @@ namespace OpenSim.Framework.Servers | |||
168 | "General", false, "show info", "show info", "Show general information about the server", HandleShow); | 171 | "General", false, "show info", "show info", "Show general information about the server", HandleShow); |
169 | 172 | ||
170 | m_console.Commands.AddCommand( | 173 | m_console.Commands.AddCommand( |
174 | "General", false, "show version", "show version", "Show server version", HandleShow); | ||
175 | |||
176 | m_console.Commands.AddCommand( | ||
171 | "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); | 177 | "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); |
172 | 178 | ||
173 | m_console.Commands.AddCommand( | 179 | m_console.Commands.AddCommand( |
@@ -206,6 +212,34 @@ namespace OpenSim.Framework.Servers | |||
206 | "General", false, "command-script", | 212 | "General", false, "command-script", |
207 | "command-script <script>", | 213 | "command-script <script>", |
208 | "Run a command script from file", HandleScript); | 214 | "Run a command script from file", HandleScript); |
215 | |||
216 | m_console.Commands.AddCommand( | ||
217 | "General", false, "show threads", | ||
218 | "show threads", | ||
219 | "Show thread status", HandleShow); | ||
220 | |||
221 | m_console.Commands.AddCommand( | ||
222 | "General", false, "threads abort", | ||
223 | "threads abort <thread-id>", | ||
224 | "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); | ||
225 | |||
226 | m_console.Commands.AddCommand( | ||
227 | "General", false, "threads show", | ||
228 | "threads show", | ||
229 | "Show thread status. Synonym for \"show threads\"", | ||
230 | (string module, string[] args) => Notice(GetThreadsReport())); | ||
231 | |||
232 | m_console.Commands.AddCommand( | ||
233 | "General", false, "force gc", | ||
234 | "force gc", | ||
235 | "Manually invoke runtime garbage collection. For debugging purposes", | ||
236 | HandleForceGc); | ||
237 | } | ||
238 | |||
239 | private void HandleForceGc(string module, string[] args) | ||
240 | { | ||
241 | Notice("Manually invoking runtime garbage collection"); | ||
242 | GC.Collect(); | ||
209 | } | 243 | } |
210 | 244 | ||
211 | public virtual void HandleShow(string module, string[] cmd) | 245 | public virtual void HandleShow(string module, string[] cmd) |
@@ -222,9 +256,17 @@ namespace OpenSim.Framework.Servers | |||
222 | ShowInfo(); | 256 | ShowInfo(); |
223 | break; | 257 | break; |
224 | 258 | ||
259 | case "version": | ||
260 | Notice(GetVersionText()); | ||
261 | break; | ||
262 | |||
225 | case "uptime": | 263 | case "uptime": |
226 | Notice(GetUptimeReport()); | 264 | Notice(GetUptimeReport()); |
227 | break; | 265 | break; |
266 | |||
267 | case "threads": | ||
268 | Notice(GetThreadsReport()); | ||
269 | break; | ||
228 | } | 270 | } |
229 | } | 271 | } |
230 | 272 | ||
@@ -537,6 +579,75 @@ namespace OpenSim.Framework.Servers | |||
537 | } | 579 | } |
538 | 580 | ||
539 | /// <summary> | 581 | /// <summary> |
582 | /// Get a report about the registered threads in this server. | ||
583 | /// </summary> | ||
584 | protected string GetThreadsReport() | ||
585 | { | ||
586 | // This should be a constant field. | ||
587 | string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}"; | ||
588 | |||
589 | StringBuilder sb = new StringBuilder(); | ||
590 | Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo(); | ||
591 | |||
592 | sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); | ||
593 | |||
594 | int timeNow = Environment.TickCount & Int32.MaxValue; | ||
595 | |||
596 | sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE"); | ||
597 | sb.Append(Environment.NewLine); | ||
598 | |||
599 | foreach (Watchdog.ThreadWatchdogInfo twi in threads) | ||
600 | { | ||
601 | Thread t = twi.Thread; | ||
602 | |||
603 | sb.AppendFormat( | ||
604 | reportFormat, | ||
605 | t.ManagedThreadId, | ||
606 | t.Name, | ||
607 | timeNow - twi.LastTick, | ||
608 | timeNow - twi.FirstTick, | ||
609 | t.Priority, | ||
610 | t.ThreadState); | ||
611 | |||
612 | sb.Append("\n"); | ||
613 | } | ||
614 | |||
615 | sb.Append("\n"); | ||
616 | |||
617 | // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting | ||
618 | // zero active threads. | ||
619 | int totalThreads = Process.GetCurrentProcess().Threads.Count; | ||
620 | if (totalThreads > 0) | ||
621 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); | ||
622 | |||
623 | sb.Append("Main threadpool (excluding script engine pools)\n"); | ||
624 | sb.Append(Util.GetThreadPoolReport()); | ||
625 | |||
626 | return sb.ToString(); | ||
627 | } | ||
628 | |||
629 | public virtual void HandleThreadsAbort(string module, string[] cmd) | ||
630 | { | ||
631 | if (cmd.Length != 3) | ||
632 | { | ||
633 | MainConsole.Instance.Output("Usage: threads abort <thread-id>"); | ||
634 | return; | ||
635 | } | ||
636 | |||
637 | int threadId; | ||
638 | if (!int.TryParse(cmd[2], out threadId)) | ||
639 | { | ||
640 | MainConsole.Instance.Output("ERROR: Thread id must be an integer"); | ||
641 | return; | ||
642 | } | ||
643 | |||
644 | if (Watchdog.AbortThread(threadId)) | ||
645 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); | ||
646 | else | ||
647 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); | ||
648 | } | ||
649 | |||
650 | /// <summary> | ||
540 | /// Console output is only possible if a console has been established. | 651 | /// Console output is only possible if a console has been established. |
541 | /// That is something that cannot be determined within this class. So | 652 | /// That is something that cannot be determined within this class. So |
542 | /// all attempts to use the console MUST be verified. | 653 | /// all attempts to use the console MUST be verified. |
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs index 4c2f586..50f306e 100644 --- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs +++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs | |||
@@ -35,11 +35,12 @@ using HttpServer; | |||
35 | using HttpServer.FormDecoders; | 35 | using HttpServer.FormDecoders; |
36 | using NUnit.Framework; | 36 | using NUnit.Framework; |
37 | using OpenSim.Framework.Servers.HttpServer; | 37 | using OpenSim.Framework.Servers.HttpServer; |
38 | using OpenSim.Tests.Common; | ||
38 | 39 | ||
39 | namespace OpenSim.Framework.Servers.Tests | 40 | namespace OpenSim.Framework.Servers.Tests |
40 | { | 41 | { |
41 | [TestFixture] | 42 | [TestFixture] |
42 | public class OSHttpTests | 43 | public class OSHttpTests : OpenSimTestCase |
43 | { | 44 | { |
44 | // we need an IHttpClientContext for our tests | 45 | // we need an IHttpClientContext for our tests |
45 | public class TestHttpClientContext: IHttpClientContext | 46 | public class TestHttpClientContext: IHttpClientContext |
diff --git a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs b/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs index 49e5061..480f2bb 100644 --- a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs +++ b/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs | |||
@@ -29,11 +29,12 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using OpenSim.Tests.Common; | ||
32 | 33 | ||
33 | namespace OpenSim.Framework.Servers.Tests | 34 | namespace OpenSim.Framework.Servers.Tests |
34 | { | 35 | { |
35 | [TestFixture] | 36 | [TestFixture] |
36 | public class VersionInfoTests | 37 | public class VersionInfoTests : OpenSimTestCase |
37 | { | 38 | { |
38 | [Test] | 39 | [Test] |
39 | public void TestVersionLength() | 40 | public void TestVersionLength() |
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs index 0dce414..95e9439 100644 --- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs +++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs | |||
@@ -24,16 +24,17 @@ | |||
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 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenMetaverse.StructuredData; | 30 | using OpenMetaverse.StructuredData; |
30 | using NUnit.Framework; | 31 | using NUnit.Framework; |
31 | 32 | using OpenSim.Tests.Common; | |
32 | 33 | ||
33 | namespace OpenSim.Framework.Tests | 34 | namespace OpenSim.Framework.Tests |
34 | { | 35 | { |
35 | [TestFixture] | 36 | [TestFixture] |
36 | public class AgentCircuitDataTest | 37 | public class AgentCircuitDataTest : OpenSimTestCase |
37 | { | 38 | { |
38 | private UUID AgentId; | 39 | private UUID AgentId; |
39 | private AvatarAppearance AvAppearance; | 40 | private AvatarAppearance AvAppearance; |
diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs index 967a355..f3be81b 100644 --- a/OpenSim/Framework/Tests/AnimationTests.cs +++ b/OpenSim/Framework/Tests/AnimationTests.cs | |||
@@ -38,7 +38,7 @@ using Animation = OpenSim.Framework.Animation; | |||
38 | namespace OpenSim.Framework.Tests | 38 | namespace OpenSim.Framework.Tests |
39 | { | 39 | { |
40 | [TestFixture] | 40 | [TestFixture] |
41 | public class AnimationTests | 41 | public class AnimationTests : OpenSimTestCase |
42 | { | 42 | { |
43 | private Animation anim1 = null; | 43 | private Animation anim1 = null; |
44 | private Animation anim2 = null; | 44 | private Animation anim2 = null; |
diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs index 6db1aa0..25d2393 100644 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ b/OpenSim/Framework/Tests/AssetBaseTest.cs | |||
@@ -30,11 +30,12 @@ using System.Collections.Generic; | |||
30 | using System.Text; | 30 | using System.Text; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Tests.Common; | ||
33 | 34 | ||
34 | namespace OpenSim.Framework.Tests | 35 | namespace OpenSim.Framework.Tests |
35 | { | 36 | { |
36 | [TestFixture] | 37 | [TestFixture] |
37 | public class AssetBaseTest | 38 | public class AssetBaseTest : OpenSimTestCase |
38 | { | 39 | { |
39 | [Test] | 40 | [Test] |
40 | public void TestContainsReferences() | 41 | public void TestContainsReferences() |
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs index c3613e6..c709860 100644 --- a/OpenSim/Framework/Tests/CacheTests.cs +++ b/OpenSim/Framework/Tests/CacheTests.cs | |||
@@ -28,11 +28,12 @@ | |||
28 | using System; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Tests.Common; | ||
31 | 32 | ||
32 | namespace OpenSim.Framework.Tests | 33 | namespace OpenSim.Framework.Tests |
33 | { | 34 | { |
34 | [TestFixture] | 35 | [TestFixture] |
35 | public class CacheTests | 36 | public class CacheTests : OpenSimTestCase |
36 | { | 37 | { |
37 | private Cache cache; | 38 | private Cache cache; |
38 | private UUID cacheItemUUID; | 39 | private UUID cacheItemUUID; |
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs index 2707afa..a56ecb4 100644 --- a/OpenSim/Framework/Tests/LocationTest.cs +++ b/OpenSim/Framework/Tests/LocationTest.cs | |||
@@ -26,11 +26,12 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using NUnit.Framework; | 28 | using NUnit.Framework; |
29 | using OpenSim.Tests.Common; | ||
29 | 30 | ||
30 | namespace OpenSim.Framework.Tests | 31 | namespace OpenSim.Framework.Tests |
31 | { | 32 | { |
32 | [TestFixture] | 33 | [TestFixture] |
33 | public class LocationTest | 34 | public class LocationTest : OpenSimTestCase |
34 | { | 35 | { |
35 | [Test] | 36 | [Test] |
36 | public void locationRegionHandleRegionHandle() | 37 | public void locationRegionHandleRegionHandle() |
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 6fde488..0fbdaf3 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -32,11 +32,12 @@ using OpenMetaverse.StructuredData; | |||
32 | using System; | 32 | using System; |
33 | using System.Globalization; | 33 | using System.Globalization; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using OpenSim.Tests.Common; | ||
35 | 36 | ||
36 | namespace OpenSim.Framework.Tests | 37 | namespace OpenSim.Framework.Tests |
37 | { | 38 | { |
38 | [TestFixture] | 39 | [TestFixture] |
39 | public class MundaneFrameworkTests | 40 | public class MundaneFrameworkTests : OpenSimTestCase |
40 | { | 41 | { |
41 | private bool m_RegionSettingsOnSaveEventFired; | 42 | private bool m_RegionSettingsOnSaveEventFired; |
42 | private bool m_RegionLightShareDataOnSaveEventFired; | 43 | private bool m_RegionLightShareDataOnSaveEventFired; |
@@ -302,10 +303,6 @@ namespace OpenSim.Framework.Tests | |||
302 | Culture.SetCurrentCulture(); | 303 | Culture.SetCurrentCulture(); |
303 | Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); | 304 | Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); |
304 | 305 | ||
305 | } | 306 | } |
306 | |||
307 | |||
308 | |||
309 | } | 307 | } |
310 | } | 308 | } \ No newline at end of file |
311 | |||
diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs index 36bc6e7..82e13e5 100644 --- a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs +++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs | |||
@@ -31,11 +31,12 @@ using NUnit.Framework; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenMetaverse.StructuredData; | 32 | using OpenMetaverse.StructuredData; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Tests.Common; | ||
34 | 35 | ||
35 | namespace OpenSim.Framework.Tests | 36 | namespace OpenSim.Framework.Tests |
36 | { | 37 | { |
37 | [TestFixture] | 38 | [TestFixture] |
38 | public class PrimeNumberHelperTests | 39 | public class PrimeNumberHelperTests : OpenSimTestCase |
39 | { | 40 | { |
40 | [Test] | 41 | [Test] |
41 | public void TestGetPrime() | 42 | public void TestGetPrime() |
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index f0d2a3f..11ca068 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs | |||
@@ -33,7 +33,7 @@ using OpenSim.Tests.Common; | |||
33 | namespace OpenSim.Framework.Tests | 33 | namespace OpenSim.Framework.Tests |
34 | { | 34 | { |
35 | [TestFixture] | 35 | [TestFixture] |
36 | public class UtilTests | 36 | public class UtilTests : OpenSimTestCase |
37 | { | 37 | { |
38 | [Test] | 38 | [Test] |
39 | public void VectorOperationTests() | 39 | public void VectorOperationTests() |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e76a37b..d206fc1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1753,12 +1753,16 @@ namespace OpenSim.Framework | |||
1753 | StringBuilder sb = new StringBuilder(); | 1753 | StringBuilder sb = new StringBuilder(); |
1754 | if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | 1754 | if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) |
1755 | { | 1755 | { |
1756 | threadPoolUsed = "SmartThreadPool"; | 1756 | // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool. |
1757 | maxThreads = m_ThreadPool.MaxThreads; | 1757 | if (m_ThreadPool != null) |
1758 | minThreads = m_ThreadPool.MinThreads; | 1758 | { |
1759 | inUseThreads = m_ThreadPool.InUseThreads; | 1759 | threadPoolUsed = "SmartThreadPool"; |
1760 | allocatedThreads = m_ThreadPool.ActiveThreads; | 1760 | maxThreads = m_ThreadPool.MaxThreads; |
1761 | waitingCallbacks = m_ThreadPool.WaitingCallbacks; | 1761 | minThreads = m_ThreadPool.MinThreads; |
1762 | inUseThreads = m_ThreadPool.InUseThreads; | ||
1763 | allocatedThreads = m_ThreadPool.ActiveThreads; | ||
1764 | waitingCallbacks = m_ThreadPool.WaitingCallbacks; | ||
1765 | } | ||
1762 | } | 1766 | } |
1763 | else if ( | 1767 | else if ( |
1764 | FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem | 1768 | FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem |
@@ -1863,6 +1867,12 @@ namespace OpenSim.Framework | |||
1863 | /// </summary> | 1867 | /// </summary> |
1864 | public static void PrintCallStack() | 1868 | public static void PrintCallStack() |
1865 | { | 1869 | { |
1870 | PrintCallStack(m_log.DebugFormat); | ||
1871 | } | ||
1872 | |||
1873 | public delegate void DebugPrinter(string msg, params Object[] parm); | ||
1874 | public static void PrintCallStack(DebugPrinter printer) | ||
1875 | { | ||
1866 | StackTrace stackTrace = new StackTrace(true); // get call stack | 1876 | StackTrace stackTrace = new StackTrace(true); // get call stack |
1867 | StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) | 1877 | StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) |
1868 | 1878 | ||
@@ -1870,7 +1880,7 @@ namespace OpenSim.Framework | |||
1870 | foreach (StackFrame stackFrame in stackFrames) | 1880 | foreach (StackFrame stackFrame in stackFrames) |
1871 | { | 1881 | { |
1872 | MethodBase mb = stackFrame.GetMethod(); | 1882 | MethodBase mb = stackFrame.GetMethod(); |
1873 | m_log.DebugFormat("{0}.{1}:{2}", mb.DeclaringType, mb.Name, stackFrame.GetFileLineNumber()); // write method name | 1883 | printer("{0}.{1}:{2}", mb.DeclaringType, mb.Name, stackFrame.GetFileLineNumber()); // write method name |
1874 | } | 1884 | } |
1875 | } | 1885 | } |
1876 | 1886 | ||