Compare commits
420 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2c893a7be | ||
|
|
3f80ac23b6 | ||
|
|
701109c8c9 | ||
|
|
5cbda393cd | ||
|
|
98d0440c42 | ||
|
|
8148d7e204 | ||
|
|
b43a6b0199 | ||
|
|
d01943fa40 | ||
|
|
b6daf4d4c6 | ||
|
|
4495ecd158 | ||
|
|
85df66db51 | ||
|
|
3024d0e61c | ||
|
|
5ac0447e0f | ||
|
|
bb42862639 | ||
|
|
39b8f339ce | ||
|
|
af99e5e74a | ||
|
|
f79800246a | ||
|
|
4c1b1d89eb | ||
|
|
a473482413 | ||
|
|
535ec23646 | ||
|
|
245d6435e3 | ||
|
|
8728d4ce6a | ||
|
|
44901f0b31 | ||
|
|
5054a07be2 | ||
|
|
2f1cc6a06a | ||
|
|
ff7693a14b | ||
|
|
e89f93c78c | ||
|
|
d51aee876d | ||
|
|
3ad03d41e6 | ||
|
|
69104f38f9 | ||
|
|
c6bb0d9662 | ||
|
|
73717f2ce7 | ||
|
|
03bc92d112 | ||
|
|
fd015c1ed7 | ||
|
|
8e548e4c8a | ||
|
|
44adf909b0 | ||
|
|
d43863af78 | ||
|
|
83c70dc914 | ||
|
|
10c1b15f12 | ||
|
|
be5c6658bb | ||
|
|
f0a936832b | ||
|
|
ce5c2ee506 | ||
|
|
bd33953c60 | ||
|
|
ab22de03b8 | ||
|
|
61af272956 | ||
|
|
e43ddcd5ea | ||
|
|
4041cb54f3 | ||
|
|
87b4f335af | ||
|
|
f9bb9191cf | ||
|
|
4ab7697f00 | ||
|
|
d1ba3ea60d | ||
|
|
e597b33926 | ||
|
|
3bb3a8f39b | ||
|
|
561626fe1b | ||
|
|
86519bd407 | ||
|
|
35a1949fb8 | ||
|
|
586a331a95 | ||
|
|
9b0f784c63 | ||
|
|
ac0f5e75bd | ||
|
|
f283ff5949 | ||
|
|
04ee863c33 | ||
|
|
16349c1368 | ||
|
|
7caf21c8a8 | ||
|
|
c98d215242 | ||
|
|
76cfab35a5 | ||
|
|
2e02f49fd9 | ||
|
|
548deb9153 | ||
|
|
150c4faa79 | ||
|
|
6693ef8288 | ||
|
|
ba93e36fce | ||
|
|
9ab580d1ea | ||
|
|
7deb2d9646 | ||
|
|
c77728ebf8 | ||
|
|
83487bfbec | ||
|
|
e6f475735f | ||
|
|
48486b137a | ||
|
|
4490020197 | ||
|
|
770caad0ad | ||
|
|
13e29ae3f7 | ||
|
|
b52ac8c5d1 | ||
|
|
97a907ad84 | ||
|
|
7ced077821 | ||
|
|
fdbd448cc7 | ||
|
|
d8c88f4894 | ||
|
|
d558bbfa35 | ||
|
|
992dc1c2c7 | ||
|
|
ce1d3e9c96 | ||
|
|
a8a712e1f8 | ||
|
|
5a71cbe530 | ||
|
|
c2bdb36c11 | ||
|
|
6d03a5d01b | ||
|
|
ad75cb2682 | ||
|
|
f46478f1df | ||
|
|
7c811c39c8 | ||
|
|
e18d6c0956 | ||
|
|
a7af8345a5 | ||
|
|
b5ecc31096 | ||
|
|
3a297c7fe6 | ||
|
|
c3243ce0ce | ||
|
|
ace552ecc5 | ||
|
|
1d75570c59 | ||
|
|
70ccc63b83 | ||
|
|
31373ee099 | ||
|
|
afaf7b5b94 | ||
|
|
6d0f66ae87 | ||
|
|
207233335e | ||
|
|
e9fbfd0905 | ||
|
|
c35f974637 | ||
|
|
a4007cbe71 | ||
|
|
d70e0b1189 | ||
|
|
a9ce40a722 | ||
|
|
8d207fd8e6 | ||
|
|
2487adf0b1 | ||
|
|
4aa725f60b | ||
|
|
0686a2fba9 | ||
|
|
b6305011db | ||
|
|
9cdf5199df | ||
|
|
632dad337b | ||
|
|
08234d0097 | ||
|
|
d68ba391fc | ||
|
|
603a140eb7 | ||
|
|
fd31f05cf0 | ||
|
|
a8152c57b3 | ||
|
|
4753d14a19 | ||
|
|
ee5e61d448 | ||
|
|
41b76c4b9e | ||
|
|
314de0fc49 | ||
|
|
93f7e4fb9d | ||
|
|
f8adf4de2f | ||
|
|
08f0274b5a | ||
|
|
94748aab84 | ||
|
|
468d1cf03e | ||
|
|
e8e6bc0c6a | ||
|
|
c7b9d460e0 | ||
|
|
e263368656 | ||
|
|
4b6a9d107d | ||
|
|
ee5454fd4a | ||
|
|
38d2d6a20c | ||
|
|
7e493b9665 | ||
|
|
b7c1a37676 | ||
|
|
4fe042aa7f | ||
|
|
a83218fd08 | ||
|
|
221af2da70 | ||
|
|
c6c6ac0a3e | ||
|
|
a5fdfd6343 | ||
|
|
72e0c77f91 | ||
|
|
862f595e5d | ||
|
|
db045e69f9 | ||
|
|
6a54cb871b | ||
|
|
3619a83b28 | ||
|
|
e3927d2868 | ||
|
|
fe503de17a | ||
|
|
5498a64a9f | ||
|
|
3148a231db | ||
|
|
bffdf20721 | ||
|
|
a4b64d4854 | ||
|
|
fe195e0a9c | ||
|
|
9d70f48207 | ||
|
|
d83df8c1cf | ||
|
|
c7c6c12146 | ||
|
|
e83a4c24ee | ||
|
|
a1669be6c3 | ||
|
|
e36799f515 | ||
|
|
186fe5f7b0 | ||
|
|
27206eccef | ||
|
|
62c0d60d3e | ||
|
|
c39342df3e | ||
|
|
458a103529 | ||
|
|
c22a37e7a6 | ||
|
|
01a8a65d75 | ||
|
|
28ced402d8 | ||
|
|
95e35fe84a | ||
|
|
3692ff2bdb | ||
|
|
7235a5fed4 | ||
|
|
614e5b52b8 | ||
|
|
35ab31fb5f | ||
|
|
636994eea6 | ||
|
|
146ac5ceda | ||
|
|
5413bfec30 | ||
|
|
f39c2cd714 | ||
|
|
e0ef2bdf81 | ||
|
|
efc09e8022 | ||
|
|
1790355f3e | ||
|
|
d0d004c6ff | ||
|
|
ee4abb681e | ||
|
|
9e3605d952 | ||
|
|
0df4927710 | ||
|
|
9d4415429d | ||
|
|
c86ac36876 | ||
|
|
4a4d800523 | ||
|
|
01c148bbce | ||
|
|
1cbe4363a3 | ||
|
|
c0254d914f | ||
|
|
53112f1e80 | ||
|
|
0f312c58ca | ||
|
|
2ca520c1eb | ||
|
|
c9b7ac2ae5 | ||
|
|
6e2ffd7050 | ||
|
|
8726748e22 | ||
|
|
73c2db9e8f | ||
|
|
c1cab3e752 | ||
|
|
713fdda7f8 | ||
|
|
baa599e5b0 | ||
|
|
014c533ebe | ||
|
|
53d87510ce | ||
|
|
43aa74d139 | ||
|
|
ada9238907 | ||
|
|
4d98cdf829 | ||
|
|
547043047e | ||
|
|
9d3b68411a | ||
|
|
470f8d3c04 | ||
|
|
da00b57d4b | ||
|
|
caedac67e0 | ||
|
|
2b5dc4eba4 | ||
|
|
39b8d01e71 | ||
|
|
fca3154982 | ||
|
|
cef158c42d | ||
|
|
177c3bcfe6 | ||
|
|
35766f2c3a | ||
|
|
e175cf543c | ||
|
|
96b0d1276e | ||
|
|
301546289e | ||
|
|
813778b39e | ||
|
|
6c3eceb197 | ||
|
|
0afc43eed7 | ||
|
|
6eb260d4eb | ||
|
|
63f1efc414 | ||
|
|
e685f7ab68 | ||
|
|
ac8f420adb | ||
|
|
fa16f132e3 | ||
|
|
7a5782c3e3 | ||
|
|
cf98691a3d | ||
|
|
09aa87ba26 | ||
|
|
38fb0430bf | ||
|
|
ec82e2fde8 | ||
|
|
fba2864cbc | ||
|
|
60c6d3e108 | ||
|
|
92f9750ded | ||
|
|
23106bce76 | ||
|
|
15acba1972 | ||
|
|
909d4dca82 | ||
|
|
5676f1d037 | ||
|
|
d864d76254 | ||
|
|
9ff4d38cc9 | ||
|
|
8dadbf706d | ||
|
|
ff968cbe43 | ||
|
|
582540657f | ||
|
|
05eeee6ee8 | ||
|
|
cd6f3b147d | ||
|
|
86f519ba57 | ||
|
|
febc6bae30 | ||
|
|
48f818bf07 | ||
|
|
c2d21bb8cc | ||
|
|
39fe1ba028 | ||
|
|
7112e860dc | ||
|
|
4606137882 | ||
|
|
8eab6b7701 | ||
|
|
71cd68eec1 | ||
|
|
168c3b78f4 | ||
|
|
d175e49e15 | ||
|
|
79624d762e | ||
|
|
3ec9eec257 | ||
|
|
e5ac4a72b7 | ||
|
|
470ea6cf70 | ||
|
|
45dc7ac7d1 | ||
|
|
2905eaa8ff | ||
|
|
deb068050b | ||
|
|
8f803c5a7d | ||
|
|
601c7998eb | ||
|
|
5a686d40de | ||
|
|
57837a1e81 | ||
|
|
5162ebd2cc | ||
|
|
1f869ab36d | ||
|
|
e912e52e15 | ||
|
|
14b0c03d5b | ||
|
|
8414ec9429 | ||
|
|
ac03b1b82f | ||
|
|
d5c999553e | ||
|
|
371df42d3f | ||
|
|
a4a0396850 | ||
|
|
83ad75b997 | ||
|
|
3f45d4ba9d | ||
|
|
2fa8bc201a | ||
|
|
e6b99ec849 | ||
|
|
e5c665384c | ||
|
|
5bb1273b3d | ||
|
|
5629f5141e | ||
|
|
15aef01b34 | ||
|
|
67a010298f | ||
|
|
7c398a532b | ||
|
|
eefd39a0d5 | ||
|
|
176b1c85c0 | ||
|
|
2da6cfde80 | ||
|
|
8068c083f6 | ||
|
|
bbe04aab95 | ||
|
|
d31a951d94 | ||
|
|
c27a158961 | ||
|
|
068e97cf0e | ||
|
|
aa45d831f3 | ||
|
|
eff8448154 | ||
|
|
badd7f1578 | ||
|
|
e12cb7bca9 | ||
|
|
23fe2a2103 | ||
|
|
e684e426af | ||
|
|
e65959b6f7 | ||
|
|
8041af6d18 | ||
|
|
56873b319b | ||
|
|
b315fab771 | ||
|
|
05342ed677 | ||
|
|
487bf31e06 | ||
|
|
6f3b2ea632 | ||
|
|
307fdeff78 | ||
|
|
8df3edcc30 | ||
|
|
a43e282efa | ||
|
|
7374690957 | ||
|
|
0c69575670 | ||
|
|
148cad1976 | ||
|
|
7db4e00b14 | ||
|
|
a00f745eba | ||
|
|
9ae335fafc | ||
|
|
6bd7639d66 | ||
|
|
c336309234 | ||
|
|
41d217321d | ||
|
|
2226dd1efb | ||
|
|
44699b07e4 | ||
|
|
6739f0752b | ||
|
|
1ebde81d6a | ||
|
|
195625b5e7 | ||
|
|
951c2702ff | ||
|
|
02b90df6ff | ||
|
|
f7c01c8e90 | ||
|
|
e8c964efaf | ||
|
|
74baab6f0f | ||
|
|
bff0ea2fc3 | ||
|
|
e474c19c40 | ||
|
|
a2a81f1bb7 | ||
|
|
c291284629 | ||
|
|
7f7ad71def | ||
|
|
7dfc0f30cc | ||
|
|
c14e67a8bb | ||
|
|
75b7e6009a | ||
|
|
63df56d613 | ||
|
|
f2e1f3e659 | ||
|
|
b1b7d3b004 | ||
|
|
f2c12d4fba | ||
|
|
3a60c9c8c8 | ||
|
|
44cd864205 | ||
|
|
f70d7013a5 | ||
|
|
ac1e902d59 | ||
|
|
b67bdee3cf | ||
|
|
83d4fa98f0 | ||
|
|
70a968b342 | ||
|
|
8e576f7511 | ||
|
|
4526424436 | ||
|
|
fd43620e87 | ||
|
|
56b8d331cb | ||
|
|
14bfba8b3b | ||
|
|
af8d3ae790 | ||
|
|
e6bb7e99be | ||
|
|
97c56adb9d | ||
|
|
f8612b0d1b | ||
|
|
a2a46a18ae | ||
|
|
1cf888b71f | ||
|
|
0109603cdc | ||
|
|
c7c750d127 | ||
|
|
b738b50cd6 | ||
|
|
351daf90f1 | ||
|
|
19d9acf63a | ||
|
|
eb40d3b6fc | ||
|
|
f5da23d9db | ||
|
|
b412bce095 | ||
|
|
0b57ddd753 | ||
|
|
d0a6d82a23 | ||
|
|
ba2792bd1f | ||
|
|
3f8c09e006 | ||
|
|
8f39268761 | ||
|
|
cd8c8d78a9 | ||
|
|
980678846d | ||
|
|
9a92d8d57e | ||
|
|
b155c601d7 | ||
|
|
536f2c085a | ||
|
|
2602d4f16e | ||
|
|
174addc426 | ||
|
|
849053681e | ||
|
|
a8d8ea7990 | ||
|
|
10e6493f9f | ||
|
|
8c4f911935 | ||
|
|
62bc85b5c7 | ||
|
|
76eba917f9 | ||
|
|
84a046eaf5 | ||
|
|
8d1d314f49 | ||
|
|
9395f12584 | ||
|
|
b97f58d597 | ||
|
|
30c36a3960 | ||
|
|
206eccc2b6 | ||
|
|
2358a623e3 | ||
|
|
87850bd6dc | ||
|
|
d80eda202f | ||
|
|
3edfa585ec | ||
|
|
fa13a6a8da | ||
|
|
9d5e7c89d9 | ||
|
|
590bf0bcc0 | ||
|
|
b199a2dea3 | ||
|
|
f1d4b8d83e | ||
|
|
0088661356 | ||
|
|
1a7e3cabc0 | ||
|
|
132d701b3e | ||
|
|
3b97241716 | ||
|
|
f82d090df3 | ||
|
|
7399d3e953 | ||
|
|
cab546ecee | ||
|
|
7dc1c7d841 | ||
|
|
fbff51f387 | ||
|
|
b714fb0c39 | ||
|
|
f37038013d | ||
|
|
5e98e2b7c7 | ||
|
|
35f8f3ff79 | ||
|
|
7ec8e7e025 | ||
|
|
c6efebdd8c | ||
|
|
760047abc5 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -26,9 +26,14 @@
|
||||
bin/Debug/*.dll
|
||||
bin/*.dll.mdb
|
||||
bin/*.db
|
||||
bin/*.db-journal
|
||||
bin/addin-db-*
|
||||
bin/*.dll
|
||||
bin/OpenSim.vshost.exe.config
|
||||
bin/OpenSim.32BitLaunch.vshost.exe.config
|
||||
bin/OpenSim.32BitLaunch.log
|
||||
UpgradeLog.XML
|
||||
_UpgradeReport_Files/
|
||||
bin/ScriptEngines/*-*-*-*-*
|
||||
bin/ScriptEngines/*.dll
|
||||
bin/ScriptEngines/*/*.dll
|
||||
@@ -61,6 +66,7 @@ Examples/*.dll
|
||||
OpenSim.build
|
||||
OpenSim.sln
|
||||
OpenSim.suo
|
||||
OpenSim.userprefs
|
||||
Prebuild/Prebuild.build
|
||||
Prebuild/Prebuild.sln
|
||||
TestResult.xml
|
||||
@@ -89,3 +95,5 @@ OpenSim/Region/ScriptEngine/test-results/
|
||||
OpenSim/Tests/Common/test-results/
|
||||
OpenSim/Tests/test-results/
|
||||
test-results/
|
||||
doc/html
|
||||
doc/doxygen.error.log
|
||||
|
||||
@@ -43,10 +43,11 @@
|
||||
<delete dir="${distbindir}/Prebuild"/>
|
||||
<delete dir="${distbindir}/%temp%"/>
|
||||
<delete dir="${distbindir}/.nant"/>
|
||||
<delete dir="${distbindir}/ThirdParty"/>
|
||||
<delete>
|
||||
<fileset basedir="${distbindir}">
|
||||
<include name="compile.bat"/>
|
||||
<include name="BUILDING.txt"/>
|
||||
<include name="BUILDING.md"/>
|
||||
<include name="Makefile"/>
|
||||
<include name="nant-color"/>
|
||||
<include name="OpenSim.*"/>
|
||||
@@ -132,17 +133,38 @@
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.server.handlers.tests">
|
||||
<arg value="./bin/OpenSim.Server.Handlers.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.server.handlers.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.services.inventoryservice.tests">
|
||||
<arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.services.inventoryservice.tests)==0}" />
|
||||
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
|
||||
<target name="torture" depends="build, find-nunit">
|
||||
<target name="test-stress" depends="build, find-nunit">
|
||||
<setenv name="MONO_THREADS_PER_CPU" value="100" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.torture">
|
||||
<arg value="./bin/OpenSim.Tests.Torture.dll" />
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.stress">
|
||||
<arg value="./bin/OpenSim.Tests.Stress.dll" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests.torture)==0}" />
|
||||
<fail message="Failures reported in stress tests." unless="${int::parse(testresult.opensim.tests.stress)==0}" />
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
|
||||
<target name="test-perf" depends="build, find-nunit">
|
||||
<setenv name="MONO_THREADS_PER_CPU" value="100" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.performance">
|
||||
<arg value="./bin/OpenSim.Tests.Performance.dll" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in performance tests." unless="${int::parse(testresult.opensim.tests.performance)==0}" />
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
|
||||
@@ -224,6 +246,16 @@
|
||||
<arg value="-xml=test-results/OpenSim.Capabilities.Handlers.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.server.handlers.tests">
|
||||
<arg value="./bin/OpenSim.Server.Handlers.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Server.Handlers.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.services.inventoryservice.tests">
|
||||
<arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Services.InventoryService.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" />
|
||||
@@ -234,6 +266,7 @@
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.services.inventoryservice.tests)==0}" />
|
||||
</target>
|
||||
|
||||
<target name="doxygen">
|
||||
|
||||
@@ -91,6 +91,7 @@ what it is today.
|
||||
* Fly-Man
|
||||
* Flyte Xevious
|
||||
* Garmin Kawaguichi
|
||||
* Gryc Ueusp
|
||||
* Imaze Rhiano
|
||||
* Intimidated
|
||||
* Jeremy Bongio (IBM)
|
||||
|
||||
@@ -572,7 +572,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
region.ExternalHostName = (string) requestData["external_address"];
|
||||
|
||||
bool persist = Convert.ToBoolean((string) requestData["persist"]);
|
||||
bool persist = Convert.ToBoolean(requestData["persist"]);
|
||||
if (persist)
|
||||
{
|
||||
// default place for region configuration files is in the
|
||||
@@ -982,8 +982,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
string lastName = (string) requestData["user_lastname"];
|
||||
string password = (string) requestData["user_password"];
|
||||
|
||||
uint regionXLocation = Convert.ToUInt32((Int32) requestData["start_region_x"]);
|
||||
uint regionYLocation = Convert.ToUInt32((Int32) requestData["start_region_y"]);
|
||||
uint regionXLocation = Convert.ToUInt32(requestData["start_region_x"]);
|
||||
uint regionYLocation = Convert.ToUInt32(requestData["start_region_y"]);
|
||||
|
||||
string email = ""; // empty string for email
|
||||
if (requestData.Contains("user_email"))
|
||||
@@ -1180,9 +1180,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
if (requestData.ContainsKey("user_password")) password = (string) requestData["user_password"];
|
||||
if (requestData.ContainsKey("start_region_x"))
|
||||
regionXLocation = Convert.ToUInt32((Int32) requestData["start_region_x"]);
|
||||
regionXLocation = Convert.ToUInt32(requestData["start_region_x"]);
|
||||
if (requestData.ContainsKey("start_region_y"))
|
||||
regionYLocation = Convert.ToUInt32((Int32) requestData["start_region_y"]);
|
||||
regionYLocation = Convert.ToUInt32(requestData["start_region_y"]);
|
||||
|
||||
// if (requestData.ContainsKey("start_lookat_x"))
|
||||
// ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
|
||||
@@ -2381,7 +2381,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
destinationItem.Description = item.Description;
|
||||
destinationItem.InvType = item.InvType;
|
||||
destinationItem.CreatorId = item.CreatorId;
|
||||
destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
|
||||
destinationItem.CreatorData = item.CreatorData;
|
||||
destinationItem.NextPermissions = item.NextPermissions;
|
||||
destinationItem.CurrentPermissions = item.CurrentPermissions;
|
||||
@@ -2436,7 +2435,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
destinationItem.Description = item.Description;
|
||||
destinationItem.InvType = item.InvType;
|
||||
destinationItem.CreatorId = item.CreatorId;
|
||||
destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
|
||||
destinationItem.CreatorData = item.CreatorData;
|
||||
destinationItem.NextPermissions = item.NextPermissions;
|
||||
destinationItem.CurrentPermissions = item.CurrentPermissions;
|
||||
@@ -2549,7 +2547,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
destinationItem.Description = item.Description;
|
||||
destinationItem.InvType = item.InvType;
|
||||
destinationItem.CreatorId = item.CreatorId;
|
||||
destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
|
||||
destinationItem.CreatorData = item.CreatorData;
|
||||
destinationItem.NextPermissions = item.NextPermissions;
|
||||
destinationItem.CurrentPermissions = item.CurrentPermissions;
|
||||
@@ -2855,7 +2852,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
inventoryItem.Description = GetStringAttribute(item,"desc","");
|
||||
inventoryItem.InvType = GetIntegerAttribute(item,"invtype",-1);
|
||||
inventoryItem.CreatorId = GetStringAttribute(item,"creatorid","");
|
||||
inventoryItem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid","");
|
||||
inventoryItem.CreatorData = GetStringAttribute(item, "creatordata", "");
|
||||
inventoryItem.NextPermissions = GetUnsignedAttribute(perms, "next", 0x7fffffff);
|
||||
inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff);
|
||||
|
||||
@@ -312,14 +312,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
// Now that everything is setup we can proceed to
|
||||
// add THIS agent to the HTTP server's handler list
|
||||
|
||||
if (!AddAgentHandler(Rest.Name,this))
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId);
|
||||
foreach (IRest handler in handlers)
|
||||
{
|
||||
handler.Close();
|
||||
}
|
||||
}
|
||||
// FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
|
||||
// have to be handled through the AddHttpHandler interface.
|
||||
// if (!AddAgentHandler(Rest.Name,this))
|
||||
// {
|
||||
// Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId);
|
||||
// foreach (IRest handler in handlers)
|
||||
// {
|
||||
// handler.Close();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -342,11 +344,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId);
|
||||
|
||||
try
|
||||
{
|
||||
RemoveAgentHandler(Rest.Name, this);
|
||||
}
|
||||
catch (KeyNotFoundException){}
|
||||
// FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
|
||||
// have to be handled through the AddHttpHandler interface.
|
||||
// try
|
||||
// {
|
||||
// RemoveAgentHandler(Rest.Name, this);
|
||||
// }
|
||||
// catch (KeyNotFoundException){}
|
||||
|
||||
foreach (IRest handler in handlers)
|
||||
{
|
||||
|
||||
@@ -297,7 +297,9 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
{
|
||||
if (!IsEnabled) return false;
|
||||
_agents.Add(agentName, handler);
|
||||
return _httpd.AddAgentHandler(agentName, handler);
|
||||
// return _httpd.AddAgentHandler(agentName, handler);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -316,7 +318,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
if (_agents[agentName] == handler)
|
||||
{
|
||||
_agents.Remove(agentName);
|
||||
return _httpd.RemoveAgentHandler(agentName, handler);
|
||||
// return _httpd.RemoveAgentHandler(agentName, handler);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -358,10 +360,10 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
_httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
|
||||
}
|
||||
_handlers = null;
|
||||
foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
|
||||
{
|
||||
_httpd.RemoveAgentHandler(h.Key, h.Value);
|
||||
}
|
||||
// foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
|
||||
// {
|
||||
// _httpd.RemoveAgentHandler(h.Key, h.Value);
|
||||
// }
|
||||
_agents = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
|
||||
if (texture == null)
|
||||
{
|
||||
//m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
|
||||
// m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
|
||||
|
||||
// Fetch locally or remotely. Misses return a 404
|
||||
texture = m_assetService.Get(textureID.ToString());
|
||||
@@ -197,7 +197,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
}
|
||||
else // it was on the cache
|
||||
{
|
||||
//m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
|
||||
// m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
|
||||
WriteTextureData(httpRequest, httpResponse, texture, format);
|
||||
return true;
|
||||
}
|
||||
@@ -219,25 +219,54 @@ namespace OpenSim.Capabilities.Handlers
|
||||
int start, end;
|
||||
if (TryParseRange(range, out start, out end))
|
||||
{
|
||||
|
||||
// Before clamping start make sure we can satisfy it in order to avoid
|
||||
// sending back the last byte instead of an error status
|
||||
if (start >= texture.Data.Length)
|
||||
{
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
|
||||
// m_log.DebugFormat(
|
||||
// "[GETTEXTURE]: Client requested range for texture {0} starting at {1} but texture has end of {2}",
|
||||
// texture.ID, start, texture.Data.Length);
|
||||
|
||||
// Stricly speaking, as per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, we should be sending back
|
||||
// Requested Range Not Satisfiable (416) here. However, it appears that at least recent implementations
|
||||
// of the Linden Lab viewer (3.2.1 and 3.3.4 and probably earlier), a viewer that has previously
|
||||
// received a very small texture may attempt to fetch bytes from the server past the
|
||||
// range of data that it received originally. Whether this happens appears to depend on whether
|
||||
// the viewer's estimation of how large a request it needs to make for certain discard levels
|
||||
// (http://wiki.secondlife.com/wiki/Image_System#Discard_Level_and_Mip_Mapping), chiefly discard
|
||||
// level 2. If this estimate is greater than the total texture size, returning a RequestedRangeNotSatisfiable
|
||||
// here will cause the viewer to treat the texture as bad and never display the full resolution
|
||||
// However, if we return PartialContent (or OK) instead, the viewer will display that resolution.
|
||||
|
||||
// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
|
||||
// response.AddHeader("Content-Range", String.Format("bytes */{0}", texture.Data.Length));
|
||||
// response.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
|
||||
response.ContentType = texture.Metadata.ContentType;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle the case where no second range value was given. This is equivalent to requesting
|
||||
// the rest of the entity.
|
||||
if (end == -1)
|
||||
end = int.MaxValue;
|
||||
|
||||
end = Utils.Clamp(end, 0, texture.Data.Length - 1);
|
||||
start = Utils.Clamp(start, 0, end);
|
||||
int len = end - start + 1;
|
||||
|
||||
//m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
|
||||
// m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
|
||||
|
||||
// Always return PartialContent, even if the range covered the entire data length
|
||||
// We were accidentally sending back 404 before in this situation
|
||||
// https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the
|
||||
// entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this.
|
||||
//
|
||||
// We also do not want to send back OK even if the whole range was satisfiable since this causes
|
||||
// HTTP textures on at least Imprudence 1.4.0-beta2 to never display the final texture quality.
|
||||
// if (end > maxEnd)
|
||||
// response.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||
// else
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
|
||||
|
||||
response.ContentLength = len;
|
||||
@@ -275,15 +304,43 @@ namespace OpenSim.Capabilities.Handlers
|
||||
// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a range header.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html,
|
||||
/// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-).
|
||||
/// Where there is no value, -1 is returned.
|
||||
/// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1
|
||||
/// for start.</remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='header'></param>
|
||||
/// <param name='start'>Start of the range. Undefined if this was not a number.</param>
|
||||
/// <param name='end'>End of the range. Will be -1 if no end specified. Undefined if there was a raw string but this was not a number.</param>
|
||||
private bool TryParseRange(string header, out int start, out int end)
|
||||
{
|
||||
start = end = 0;
|
||||
|
||||
if (header.StartsWith("bytes="))
|
||||
{
|
||||
string[] rangeValues = header.Substring(6).Split('-');
|
||||
|
||||
if (rangeValues.Length == 2)
|
||||
{
|
||||
if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end))
|
||||
if (!Int32.TryParse(rangeValues[0], out start))
|
||||
return false;
|
||||
|
||||
string rawEnd = rangeValues[1];
|
||||
|
||||
if (rawEnd == "")
|
||||
{
|
||||
end = -1;
|
||||
return true;
|
||||
}
|
||||
else if (Int32.TryParse(rawEnd, out end))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock;
|
||||
namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetTextureHandlerTests
|
||||
public class GetTextureHandlerTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestTextureNotFound()
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace OpenSim.Data
|
||||
public UUID folderID;
|
||||
public UUID agentID;
|
||||
public UUID parentFolderID;
|
||||
|
||||
public XInventoryFolder Clone()
|
||||
{
|
||||
return (XInventoryFolder)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class XInventoryItem
|
||||
@@ -64,6 +69,11 @@ namespace OpenSim.Data
|
||||
public UUID avatarID;
|
||||
public UUID parentFolderID;
|
||||
public int inventoryGroupPermissions;
|
||||
|
||||
public XInventoryItem Clone()
|
||||
{
|
||||
return (XInventoryItem)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IXInventoryData
|
||||
@@ -106,7 +116,22 @@ namespace OpenSim.Data
|
||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
||||
bool DeleteItems(string[] fields, string[] vals);
|
||||
|
||||
bool MoveItem(string id, string newParent);
|
||||
/// <summary>
|
||||
/// Move an item to another folder.
|
||||
/// </summary>
|
||||
/// <returns>/returns>
|
||||
/// <param name='id'>UUID of the item</param>
|
||||
/// <param name='newParent'>UUID of the new parent folder.</param>
|
||||
bool MoveItem(string id, string newParentFolderID);
|
||||
|
||||
/// <summary>
|
||||
/// Move a folder to another folder.
|
||||
/// </summary>
|
||||
/// <returns>/returns>
|
||||
/// <param name='id'>UUID of the item</param>
|
||||
/// <param name='newParent'>UUID of the new parent folder.</param>
|
||||
bool MoveFolder(string id, string newParentFolderID);
|
||||
|
||||
XInventoryItem[] GetActiveGestures(UUID principalID);
|
||||
int GetAssetPermissions(UUID principalID, UUID assetID);
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ namespace OpenSim.Data.MSSQL
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(
|
||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private MSSQLGenericTableHandler<XInventoryFolder> m_Folders;
|
||||
private MSSQLFolderHandler m_Folders;
|
||||
private MSSQLItemHandler m_Items;
|
||||
|
||||
public MSSQLXInventoryData(string conn, string realm)
|
||||
{
|
||||
m_Folders = new MSSQLGenericTableHandler<XInventoryFolder>(
|
||||
m_Folders = new MSSQLFolderHandler(
|
||||
conn, "inventoryfolders", "InventoryStore");
|
||||
m_Items = new MSSQLItemHandler(
|
||||
conn, "inventoryitems", String.Empty);
|
||||
@@ -85,6 +85,7 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
return m_Folders.Delete(field, val);
|
||||
}
|
||||
|
||||
public bool DeleteFolders(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Folders.Delete(fields, vals);
|
||||
@@ -94,15 +95,22 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
return m_Items.Delete(field, val);
|
||||
}
|
||||
|
||||
public bool DeleteItems(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Items.Delete(fields, vals);
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
return m_Items.MoveItem(id, newParent);
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParent)
|
||||
{
|
||||
return m_Folders.MoveFolder(id, newParent);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
return m_Items.GetActiveGestures(principalID);
|
||||
@@ -114,7 +122,7 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
}
|
||||
|
||||
public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem>
|
||||
public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem>
|
||||
{
|
||||
public MSSQLItemHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
@@ -123,70 +131,163 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return cmd.ExecuteNonQuery() == 0 ? false : true;
|
||||
UUID oldParent = retrievedItems[0].parentFolderID;
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParent);
|
||||
IncrementFolderVersion(newParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
int perms = 0;
|
||||
|
||||
if (reader.Read())
|
||||
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||
|
||||
int perms = 0;
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryItem item)
|
||||
{
|
||||
if (!base.Store(item))
|
||||
return false;
|
||||
string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
|
||||
IncrementFolderVersion(item.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder>
|
||||
{
|
||||
public MSSQLFolderHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParentFolderID)
|
||||
{
|
||||
XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
|
||||
|
||||
if (folders.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParentFolderUUID = folders[0].parentFolderID;
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParentFolderUUID);
|
||||
IncrementFolderVersion(newParentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryFolder folder)
|
||||
{
|
||||
if (!base.Store(folder))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(folder.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new()
|
||||
{
|
||||
public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
|
||||
|
||||
protected bool IncrementFolderVersion(UUID folderID)
|
||||
{
|
||||
return IncrementFolderVersion(folderID.ToString());
|
||||
}
|
||||
|
||||
protected bool IncrementFolderVersion(string folderID)
|
||||
{
|
||||
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
|
||||
// Util.PrintCallStack();
|
||||
|
||||
string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
cmd.Parameters.AddWithValue("@folderID", folderID);
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
@@ -194,9 +295,11 @@ namespace OpenSim.Data.MSSQL
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public virtual bool Store(T row)
|
||||
{
|
||||
// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked");
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
string query = "";
|
||||
@@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public virtual bool Delete(string[] fields, string[] keys)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}",
|
||||
// string.Join(",", fields), string.Join(",", keys));
|
||||
|
||||
if (fields.Length != keys.Length)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -719,95 +719,99 @@ namespace OpenSim.Data.MySQL
|
||||
RegionLightShareData nWP = new RegionLightShareData();
|
||||
nWP.OnSave += StoreRegionWindlightSettings;
|
||||
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
string command = "select * from `regionwindlight` where region_id = ?regionID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
|
||||
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
if (!result.Read())
|
||||
dbcon.Open();
|
||||
|
||||
string command = "select * from `regionwindlight` where region_id = ?regionID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
//No result, so store our default windlight profile and return it
|
||||
nWP.regionID = regionUUID;
|
||||
StoreRegionWindlightSettings(nWP);
|
||||
return nWP;
|
||||
}
|
||||
else
|
||||
{
|
||||
nWP.regionID = DBGuid.FromDB(result["region_id"]);
|
||||
nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
|
||||
nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
|
||||
nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
|
||||
nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
|
||||
nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
|
||||
nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
|
||||
nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
|
||||
nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
|
||||
nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
|
||||
nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
|
||||
nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
|
||||
nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
|
||||
nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
|
||||
nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
|
||||
nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
|
||||
nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
|
||||
nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
|
||||
UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
|
||||
nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
|
||||
nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
|
||||
nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
|
||||
nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
|
||||
nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
|
||||
nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
|
||||
nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
|
||||
nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
|
||||
nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
|
||||
nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
|
||||
nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
|
||||
nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
|
||||
nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
|
||||
nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
|
||||
nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
|
||||
nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
|
||||
nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
|
||||
nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
|
||||
nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
|
||||
nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
|
||||
nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
|
||||
nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
|
||||
nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
|
||||
nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
|
||||
nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
|
||||
nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
|
||||
nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
|
||||
nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
|
||||
nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
|
||||
nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
|
||||
nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
|
||||
nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
|
||||
nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
|
||||
nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
|
||||
nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
|
||||
nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
|
||||
nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
|
||||
nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
|
||||
nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
|
||||
nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
|
||||
nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
|
||||
nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
|
||||
nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
|
||||
nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
|
||||
nWP.valid = true;
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
|
||||
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
if (!result.Read())
|
||||
{
|
||||
//No result, so store our default windlight profile and return it
|
||||
nWP.regionID = regionUUID;
|
||||
StoreRegionWindlightSettings(nWP);
|
||||
return nWP;
|
||||
}
|
||||
else
|
||||
{
|
||||
nWP.regionID = DBGuid.FromDB(result["region_id"]);
|
||||
nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
|
||||
nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
|
||||
nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
|
||||
nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
|
||||
nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
|
||||
nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
|
||||
nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
|
||||
nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
|
||||
nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
|
||||
nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
|
||||
nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
|
||||
nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
|
||||
nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
|
||||
nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
|
||||
nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
|
||||
nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
|
||||
nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
|
||||
UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
|
||||
nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
|
||||
nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
|
||||
nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
|
||||
nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
|
||||
nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
|
||||
nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
|
||||
nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
|
||||
nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
|
||||
nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
|
||||
nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
|
||||
nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
|
||||
nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
|
||||
nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
|
||||
nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
|
||||
nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
|
||||
nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
|
||||
nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
|
||||
nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
|
||||
nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
|
||||
nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
|
||||
nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
|
||||
nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
|
||||
nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
|
||||
nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
|
||||
nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
|
||||
nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
|
||||
nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
|
||||
nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
|
||||
nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
|
||||
nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
|
||||
nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
|
||||
nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
|
||||
nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
|
||||
nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
|
||||
nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
|
||||
nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
|
||||
nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
|
||||
nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
|
||||
nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
|
||||
nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
|
||||
nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
|
||||
nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
|
||||
nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
|
||||
nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
|
||||
nWP.valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nWP;
|
||||
}
|
||||
|
||||
@@ -853,118 +857,124 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public void StoreRegionWindlightSettings(RegionLightShareData wl)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
|
||||
cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
|
||||
cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
|
||||
cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
|
||||
cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
|
||||
cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
|
||||
cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
|
||||
cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
|
||||
cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
|
||||
cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
|
||||
cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
|
||||
cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
|
||||
cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
|
||||
cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
|
||||
cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
|
||||
cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
|
||||
cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
|
||||
cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
|
||||
cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
|
||||
cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
|
||||
cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
|
||||
cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
|
||||
cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
|
||||
cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
|
||||
cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
|
||||
|
||||
cmd.Parameters.AddWithValue("region_id", wl.regionID);
|
||||
cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
|
||||
cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
|
||||
cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
|
||||
cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
|
||||
cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
|
||||
cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
|
||||
cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
|
||||
cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
|
||||
cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
|
||||
cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
|
||||
cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
|
||||
cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
|
||||
cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
|
||||
cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
|
||||
cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
|
||||
cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
|
||||
cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
|
||||
cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
|
||||
cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
|
||||
cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
|
||||
cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
|
||||
cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
|
||||
cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
|
||||
cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
|
||||
cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
|
||||
cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
|
||||
cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
|
||||
cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
|
||||
cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
|
||||
cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
|
||||
cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
|
||||
cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
|
||||
cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
|
||||
cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
|
||||
cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
|
||||
cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
|
||||
cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
|
||||
cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
|
||||
cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
|
||||
cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
|
||||
cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
|
||||
cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
|
||||
cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
|
||||
cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
|
||||
cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
|
||||
cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
|
||||
cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
|
||||
cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
|
||||
cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
|
||||
cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
|
||||
cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
|
||||
cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
|
||||
cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
|
||||
cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
|
||||
cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
|
||||
cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
|
||||
cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
|
||||
cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
|
||||
cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
|
||||
cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
|
||||
cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
|
||||
cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
|
||||
cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
|
||||
cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
|
||||
cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
|
||||
cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
|
||||
cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
|
||||
cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
|
||||
|
||||
cmd.Parameters.AddWithValue("region_id", wl.regionID);
|
||||
cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
|
||||
cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
|
||||
cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
|
||||
cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
|
||||
cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
|
||||
cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
|
||||
cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
|
||||
cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
|
||||
cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
|
||||
cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
|
||||
cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
|
||||
cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
|
||||
cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
|
||||
cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
|
||||
cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
|
||||
cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
|
||||
cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
|
||||
cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
|
||||
cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
|
||||
cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
|
||||
cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
|
||||
cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
|
||||
cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
|
||||
cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
|
||||
cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
|
||||
cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
|
||||
cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
|
||||
cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
|
||||
cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
|
||||
cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
|
||||
cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
|
||||
cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
|
||||
cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
|
||||
cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
|
||||
cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
|
||||
cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
|
||||
cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
|
||||
cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
|
||||
cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
|
||||
cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
|
||||
cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
|
||||
cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
|
||||
cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
|
||||
cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
|
||||
cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
|
||||
cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
|
||||
cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
|
||||
cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegionWindlightSettings(UUID regionID)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
|
||||
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
||||
ExecuteNonQuery(cmd);
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
|
||||
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -972,26 +982,29 @@ namespace OpenSim.Data.MySQL
|
||||
#region RegionEnvironmentSettings
|
||||
public string LoadRegionEnvironmentSettings(UUID regionUUID)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
string command = "select * from `regionenvironment` where region_id = ?region_id";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
|
||||
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
if (!result.Read())
|
||||
dbcon.Open();
|
||||
|
||||
string command = "select * from `regionenvironment` where region_id = ?region_id";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToString(result["llsd_settings"]);
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
|
||||
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
if (!result.Read())
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToString(result["llsd_settings"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -999,33 +1012,39 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
|
||||
|
||||
cmd.Parameters.AddWithValue("region_id", regionUUID);
|
||||
cmd.Parameters.AddWithValue("llsd_settings", settings);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
|
||||
|
||||
cmd.Parameters.AddWithValue("region_id", regionUUID);
|
||||
cmd.Parameters.AddWithValue("llsd_settings", settings);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegionEnvironmentSettings(UUID regionUUID)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
lock (m_dbLock)
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
|
||||
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
|
||||
ExecuteNonQuery(cmd);
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
|
||||
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using MySql.Data.MySqlClient;
|
||||
using OpenMetaverse;
|
||||
@@ -41,12 +42,12 @@ namespace OpenSim.Data.MySQL
|
||||
/// </summary>
|
||||
public class MySQLXInventoryData : IXInventoryData
|
||||
{
|
||||
private MySQLGenericTableHandler<XInventoryFolder> m_Folders;
|
||||
private MySqlFolderHandler m_Folders;
|
||||
private MySqlItemHandler m_Items;
|
||||
|
||||
public MySQLXInventoryData(string conn, string realm)
|
||||
{
|
||||
m_Folders = new MySQLGenericTableHandler<XInventoryFolder>(
|
||||
m_Folders = new MySqlFolderHandler(
|
||||
conn, "inventoryfolders", "InventoryStore");
|
||||
m_Items = new MySqlItemHandler(
|
||||
conn, "inventoryitems", String.Empty);
|
||||
@@ -105,6 +106,11 @@ namespace OpenSim.Data.MySQL
|
||||
return m_Items.MoveItem(id, newParent);
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParent)
|
||||
{
|
||||
return m_Folders.MoveFolder(id, newParent);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
return m_Items.GetActiveGestures(principalID);
|
||||
@@ -116,24 +122,71 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem>
|
||||
public class MySqlItemHandler : MySqlInventoryHandler<XInventoryItem>
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public MySqlItemHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Delete(string field, string val)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!base.Delete(field, val))
|
||||
return false;
|
||||
|
||||
// Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
|
||||
// IncrementFolderVersion(retrievedItems[0].parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Delete(string[] fields, string[] vals)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(fields, vals);
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!base.Delete(fields, vals))
|
||||
return false;
|
||||
|
||||
HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>();
|
||||
|
||||
Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
|
||||
|
||||
foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
|
||||
IncrementFolderVersion(deletedItemFolderUUID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParent = retrievedItems[0].parentFolderID;
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
|
||||
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
|
||||
cmd.Parameters.AddWithValue("?InventoryID", id);
|
||||
|
||||
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
||||
if (ExecuteNonQuery(cmd) == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParent);
|
||||
IncrementFolderVersion(newParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
@@ -184,6 +237,73 @@ namespace OpenSim.Data.MySQL
|
||||
if (!base.Store(item))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(item.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MySqlFolderHandler : MySqlInventoryHandler<XInventoryFolder>
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public MySqlFolderHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParentFolderID)
|
||||
{
|
||||
XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
|
||||
|
||||
if (folders.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParentFolderUUID = folders[0].parentFolderID;
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
cmd.CommandText
|
||||
= String.Format(
|
||||
"update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm);
|
||||
cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID);
|
||||
cmd.Parameters.AddWithValue("?folderID", id);
|
||||
|
||||
if (ExecuteNonQuery(cmd) == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParentFolderUUID);
|
||||
IncrementFolderVersion(newParentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryFolder folder)
|
||||
{
|
||||
if (!base.Store(folder))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(folder.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MySqlInventoryHandler<T> : MySQLGenericTableHandler<T> where T: class, new()
|
||||
{
|
||||
public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {}
|
||||
|
||||
protected bool IncrementFolderVersion(UUID folderID)
|
||||
{
|
||||
return IncrementFolderVersion(folderID.ToString());
|
||||
}
|
||||
|
||||
protected bool IncrementFolderVersion(string folderID)
|
||||
{
|
||||
// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID);
|
||||
// Util.PrintCallStack();
|
||||
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
@@ -193,7 +313,7 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
|
||||
cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString());
|
||||
cmd.Parameters.AddWithValue("?folderID", folderID);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -205,9 +325,11 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
dbcon.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,11 +112,14 @@ namespace OpenSim.Data.Null
|
||||
// Find region data
|
||||
List<RegionData> ret = new List<RegionData>();
|
||||
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
lock (m_regionData)
|
||||
{
|
||||
// m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
{
|
||||
// m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
|
||||
if (queryMatch(r.RegionName.ToLower()))
|
||||
ret.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.Count > 0)
|
||||
@@ -132,10 +135,13 @@ namespace OpenSim.Data.Null
|
||||
|
||||
List<RegionData> ret = new List<RegionData>();
|
||||
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
lock (m_regionData)
|
||||
{
|
||||
if (r.posX == posX && r.posY == posY)
|
||||
ret.Add(r);
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
{
|
||||
if (r.posX == posX && r.posY == posY)
|
||||
ret.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.Count > 0)
|
||||
@@ -149,8 +155,11 @@ namespace OpenSim.Data.Null
|
||||
if (m_useStaticInstance && Instance != this)
|
||||
return Instance.Get(regionID, scopeID);
|
||||
|
||||
if (m_regionData.ContainsKey(regionID))
|
||||
return m_regionData[regionID];
|
||||
lock (m_regionData)
|
||||
{
|
||||
if (m_regionData.ContainsKey(regionID))
|
||||
return m_regionData[regionID];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -162,10 +171,13 @@ namespace OpenSim.Data.Null
|
||||
|
||||
List<RegionData> ret = new List<RegionData>();
|
||||
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
lock (m_regionData)
|
||||
{
|
||||
if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY)
|
||||
ret.Add(r);
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
{
|
||||
if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY)
|
||||
ret.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -179,7 +191,10 @@ namespace OpenSim.Data.Null
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID);
|
||||
|
||||
m_regionData[data.RegionID] = data;
|
||||
lock (m_regionData)
|
||||
{
|
||||
m_regionData[data.RegionID] = data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -189,10 +204,13 @@ namespace OpenSim.Data.Null
|
||||
if (m_useStaticInstance && Instance != this)
|
||||
return Instance.SetDataItem(regionID, item, value);
|
||||
|
||||
if (!m_regionData.ContainsKey(regionID))
|
||||
return false;
|
||||
lock (m_regionData)
|
||||
{
|
||||
if (!m_regionData.ContainsKey(regionID))
|
||||
return false;
|
||||
|
||||
m_regionData[regionID].Data[item] = value;
|
||||
m_regionData[regionID].Data[item] = value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -204,10 +222,13 @@ namespace OpenSim.Data.Null
|
||||
|
||||
// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID);
|
||||
|
||||
if (!m_regionData.ContainsKey(regionID))
|
||||
return false;
|
||||
lock (m_regionData)
|
||||
{
|
||||
if (!m_regionData.ContainsKey(regionID))
|
||||
return false;
|
||||
|
||||
m_regionData.Remove(regionID);
|
||||
m_regionData.Remove(regionID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -237,10 +258,13 @@ namespace OpenSim.Data.Null
|
||||
|
||||
List<RegionData> ret = new List<RegionData>();
|
||||
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
lock (m_regionData)
|
||||
{
|
||||
if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0)
|
||||
ret.Add(r);
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
{
|
||||
if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0)
|
||||
ret.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -202,7 +202,8 @@ namespace OpenSim.Data.SQLite
|
||||
/// <returns>True if exist, or false.</returns>
|
||||
override public bool ExistsAsset(UUID uuid)
|
||||
{
|
||||
lock (this) {
|
||||
lock (this)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
|
||||
@@ -353,12 +354,13 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +82,14 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
AuthenticationData ret = new AuthenticationData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
IDataReader result;
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID");
|
||||
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||
using (SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||
|
||||
IDataReader result = ExecuteReader(cmd, m_Connection);
|
||||
result = ExecuteReader(cmd, m_Connection);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -121,10 +124,6 @@ namespace OpenSim.Data.SQLite
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
//CloseCommand(cmd);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -140,84 +139,81 @@ namespace OpenSim.Data.SQLite
|
||||
foreach (object o in data.Data.Values)
|
||||
values[i++] = o.ToString();
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
if (Get(data.PrincipalID) != null)
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
|
||||
|
||||
string update = "update `" + m_Realm + "` set ";
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
if (Get(data.PrincipalID) != null)
|
||||
{
|
||||
if (!first)
|
||||
update += ", ";
|
||||
update += "`" + field + "` = :" + field;
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
update += " where UUID = :UUID";
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||
|
||||
cmd.CommandText = update;
|
||||
try
|
||||
{
|
||||
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||
string update = "update `" + m_Realm + "` set ";
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
if (!first)
|
||||
update += ", ";
|
||||
update += "`" + field + "` = :" + field;
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
update += " where UUID = :UUID";
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||
|
||||
cmd.CommandText = update;
|
||||
try
|
||||
{
|
||||
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||
{
|
||||
//CloseCommand(cmd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[SQLITE]: Exception storing authentication data", e);
|
||||
//CloseCommand(cmd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
m_log.Error("[SQLITE]: Exception storing authentication data", e);
|
||||
//CloseCommand(cmd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values (:UUID, :" + String.Join(", :", fields) + ")";
|
||||
|
||||
else
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values (:UUID, :" + String.Join(", :", fields) + ")";
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||
foreach (string field in fields)
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||
foreach (string field in fields)
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||
cmd.CommandText = insert;
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
try
|
||||
{
|
||||
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||
try
|
||||
{
|
||||
//CloseCommand(cmd);
|
||||
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//CloseCommand(cmd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//CloseCommand(cmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
|
||||
"` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'");
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
using (SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
|
||||
"` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"))
|
||||
{
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -227,16 +223,13 @@ namespace OpenSim.Data.SQLite
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
|
||||
"', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))");
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
|
||||
"', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"))
|
||||
{
|
||||
cmd.Dispose();
|
||||
return true;
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,28 +238,22 @@ namespace OpenSim.Data.SQLite
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
|
||||
" minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')");
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
|
||||
" minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"))
|
||||
{
|
||||
cmd.Dispose();
|
||||
return true;
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoExpire()
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')");
|
||||
ExecuteNonQuery(cmd, m_Connection);
|
||||
|
||||
cmd.Dispose();
|
||||
using (SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"))
|
||||
ExecuteNonQuery(cmd, m_Connection);
|
||||
|
||||
m_LastExpire = System.Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,23 +56,17 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
public bool Delete(UUID principalID, string name)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue(":Name", name);
|
||||
|
||||
try
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue(":Name", name);
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//CloseCommand(cmd);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,12 +104,13 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID";
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||
|
||||
return DoLoad(cmd, regionID, create);
|
||||
return DoLoad(cmd, regionID, create);
|
||||
}
|
||||
}
|
||||
|
||||
private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
|
||||
@@ -186,38 +187,40 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
IDataReader r = null;
|
||||
|
||||
names.Remove("EstateID");
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
|
||||
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
|
||||
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Clear();
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||
else
|
||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||
}
|
||||
else
|
||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
r = cmd.ExecuteReader();
|
||||
|
||||
r.Read();
|
||||
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
@@ -239,26 +242,27 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID";
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = sql;
|
||||
|
||||
foreach (string name in FieldList)
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||
else
|
||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||
}
|
||||
}
|
||||
cmd.CommandText = sql;
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||
else
|
||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
SaveBanList(es);
|
||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||
@@ -270,12 +274,15 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
es.ClearBans();
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
IDataReader r;
|
||||
|
||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
@@ -294,60 +301,64 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
private void SaveBanList(EstateSettings es)
|
||||
{
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )";
|
||||
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )";
|
||||
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SaveUUIDList(uint EstateID, string table, UUID[] data)
|
||||
{
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )";
|
||||
|
||||
foreach (UUID uuid in data)
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )";
|
||||
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID[] LoadUUIDList(uint EstateID, string table)
|
||||
{
|
||||
List<UUID> uuids = new List<UUID>();
|
||||
IDataReader r;
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", EstateID);
|
||||
|
||||
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
||||
cmd.Parameters.AddWithValue(":EstateID", EstateID);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
@@ -367,12 +378,13 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID";
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
||||
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
||||
|
||||
return DoLoad(cmd, UUID.Zero, false);
|
||||
return DoLoad(cmd, UUID.Zero, false);
|
||||
}
|
||||
}
|
||||
|
||||
public List<EstateSettings> LoadEstateSettingsAll()
|
||||
@@ -391,13 +403,15 @@ namespace OpenSim.Data.SQLite
|
||||
List<int> result = new List<int>();
|
||||
|
||||
string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName";
|
||||
IDataReader r;
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateName", search);
|
||||
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateName", search);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
@@ -413,12 +427,14 @@ namespace OpenSim.Data.SQLite
|
||||
List<int> result = new List<int>();
|
||||
|
||||
string sql = "select EstateID from estate_settings";
|
||||
IDataReader r;
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
|
||||
cmd.CommandText = sql;
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
@@ -434,13 +450,15 @@ namespace OpenSim.Data.SQLite
|
||||
List<int> result = new List<int>();
|
||||
|
||||
string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner";
|
||||
IDataReader r;
|
||||
|
||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateOwner", ownerID);
|
||||
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue(":EstateOwner", ownerID);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
r = cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
|
||||
@@ -90,12 +90,5 @@ namespace OpenSim.Data.SQLite
|
||||
return cmd.ExecuteReader();
|
||||
}
|
||||
}
|
||||
|
||||
protected void CloseCommand(SqliteCommand cmd)
|
||||
{
|
||||
cmd.Connection.Close();
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
public FriendsData[] GetFriends(string userID)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString());
|
||||
|
||||
return DoQuery(cmd);
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString());
|
||||
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string friend)
|
||||
@@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
public bool Delete(string principalID, string friend)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue(":Friend", friend);
|
||||
|
||||
cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
|
||||
cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue(":Friend", friend);
|
||||
|
||||
ExecuteNonQuery(cmd, m_Connection);
|
||||
ExecuteNonQuery(cmd, m_Connection);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,34 +120,35 @@ namespace OpenSim.Data.SQLite
|
||||
}
|
||||
}
|
||||
|
||||
public T[] Get(string field, string key)
|
||||
public virtual T[] Get(string field, string key)
|
||||
{
|
||||
return Get(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public T[] Get(string[] fields, string[] keys)
|
||||
public virtual T[] Get(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return new T[0];
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
for (int i = 0 ; i < fields.Length ; i++)
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
||||
for (int i = 0 ; i < fields.Length ; i++)
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("select * from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("select * from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
|
||||
protected T[] DoQuery(SqliteCommand cmd)
|
||||
@@ -212,53 +213,55 @@ namespace OpenSim.Data.SQLite
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public T[] Get(string where)
|
||||
public virtual T[] Get(string where)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
string query = String.Format("select * from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
string query = String.Format("select * from {0} where {1}",
|
||||
m_Realm, where);
|
||||
cmd.CommandText = query;
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
return DoQuery(cmd);
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Store(T row)
|
||||
public virtual bool Store(T row)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
string query = "";
|
||||
List<String> names = new List<String>();
|
||||
List<String> values = new List<String>();
|
||||
|
||||
foreach (FieldInfo fi in m_Fields.Values)
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
names.Add(fi.Name);
|
||||
values.Add(":" + fi.Name);
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString()));
|
||||
}
|
||||
string query = "";
|
||||
List<String> names = new List<String>();
|
||||
List<String> values = new List<String>();
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
foreach (FieldInfo fi in m_Fields.Values)
|
||||
{
|
||||
names.Add(kvp.Key);
|
||||
values.Add(":" + kvp.Key);
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value));
|
||||
names.Add(fi.Name);
|
||||
values.Add(":" + fi.Name);
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString()));
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
{
|
||||
names.Add(kvp.Key);
|
||||
values.Add(":" + kvp.Key);
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value));
|
||||
}
|
||||
}
|
||||
|
||||
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -267,28 +270,29 @@ namespace OpenSim.Data.SQLite
|
||||
return Delete(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public bool Delete(string[] fields, string[] keys)
|
||||
public virtual bool Delete(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return false;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
for (int i = 0 ; i < fields.Length ; i++)
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
||||
for (int i = 0 ; i < fields.Length ; i++)
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("delete from {0} where {1}", m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
return ExecuteNonQuery(cmd, m_Connection) > 0;
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("delete from {0} where {1}", m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
return ExecuteNonQuery(cmd, m_Connection) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1366,6 +1366,12 @@ namespace OpenSim.Data.SQLite
|
||||
createCol(land, "UserLookAtZ", typeof(Double));
|
||||
createCol(land, "AuthbuyerID", typeof(String));
|
||||
createCol(land, "OtherCleanTime", typeof(Int32));
|
||||
createCol(land, "MediaType", typeof(String));
|
||||
createCol(land, "MediaDescription", typeof(String));
|
||||
createCol(land, "MediaSize", typeof(String));
|
||||
createCol(land, "MediaLoop", typeof(Boolean));
|
||||
createCol(land, "ObscureMedia", typeof(Boolean));
|
||||
createCol(land, "ObscureMusic", typeof(Boolean));
|
||||
|
||||
land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] };
|
||||
|
||||
@@ -1781,9 +1787,15 @@ namespace OpenSim.Data.SQLite
|
||||
newData.PassHours = Convert.ToSingle(row["PassHours"]);
|
||||
newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
|
||||
newData.SnapshotID = (UUID)(String)row["SnapshotUUID"];
|
||||
newData.MediaType = (String)row["MediaType"];
|
||||
newData.MediaDescription = (String)row["MediaDescription"];
|
||||
newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]);
|
||||
newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]);
|
||||
newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]);
|
||||
newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
|
||||
newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
|
||||
try
|
||||
{
|
||||
|
||||
newData.UserLocation =
|
||||
new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
|
||||
Convert.ToSingle(row["UserLocationZ"]));
|
||||
@@ -2197,10 +2209,10 @@ namespace OpenSim.Data.SQLite
|
||||
row["OtherCleanTime"] = land.OtherCleanTime;
|
||||
row["MediaType"] = land.MediaType;
|
||||
row["MediaDescription"] = land.MediaDescription;
|
||||
row["MediaSize"] = land.MediaWidth.ToString() + "," + land.MediaHeight.ToString();
|
||||
row["MediaLoop"] = land.MediaLoop.ToString();
|
||||
row["ObscureMusic"] = land.ObscureMusic.ToString();
|
||||
row["ObscureMedia"] = land.ObscureMedia.ToString();
|
||||
row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight);
|
||||
row["MediaLoop"] = land.MediaLoop;
|
||||
row["ObscureMusic"] = land.ObscureMusic;
|
||||
row["ObscureMedia"] = land.ObscureMedia;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -66,20 +66,21 @@ namespace OpenSim.Data.SQLite
|
||||
if (words.Length > 2)
|
||||
return new UserAccountData[0];
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
if (words.Length == 1)
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
|
||||
m_Realm, scopeID.ToString(), words[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
|
||||
m_Realm, scopeID.ToString(), words[0], words[1]);
|
||||
}
|
||||
if (words.Length == 1)
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
|
||||
m_Realm, scopeID.ToString(), words[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
|
||||
m_Realm, scopeID.ToString(), words[0], words[1]);
|
||||
}
|
||||
|
||||
return DoQuery(cmd);
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private SQLiteGenericTableHandler<XInventoryFolder> m_Folders;
|
||||
private SqliteFolderHandler m_Folders;
|
||||
private SqliteItemHandler m_Items;
|
||||
|
||||
public SQLiteXInventoryData(string conn, string realm)
|
||||
@@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite
|
||||
if (Util.IsWindows())
|
||||
Util.LoadArchSpecificWindowsDll("sqlite3.dll");
|
||||
|
||||
m_Folders = new SQLiteGenericTableHandler<XInventoryFolder>(
|
||||
m_Folders = new SqliteFolderHandler(
|
||||
conn, "inventoryfolders", "XInventoryStore");
|
||||
m_Items = new SqliteItemHandler(
|
||||
conn, "inventoryitems", String.Empty);
|
||||
@@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite
|
||||
return m_Items.MoveItem(id, newParent);
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParent)
|
||||
{
|
||||
return m_Folders.MoveFolder(id, newParent);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
return m_Items.GetActiveGestures(principalID);
|
||||
@@ -125,44 +130,106 @@ namespace OpenSim.Data.SQLite
|
||||
}
|
||||
}
|
||||
|
||||
public class SqliteItemHandler : SQLiteGenericTableHandler<XInventoryItem>
|
||||
public class SqliteItemHandler : SqliteInventoryHandler<XInventoryItem>
|
||||
{
|
||||
public SqliteItemHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryItem item)
|
||||
{
|
||||
if (!base.Store(item))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(item.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Delete(string field, string val)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!base.Delete(field, val))
|
||||
return false;
|
||||
|
||||
// Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
|
||||
// IncrementFolderVersion(retrievedItems[0].parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Delete(string[] fields, string[] vals)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(fields, vals);
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!base.Delete(fields, vals))
|
||||
return false;
|
||||
|
||||
HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>();
|
||||
|
||||
Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
|
||||
|
||||
foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
|
||||
IncrementFolderVersion(deletedItemFolderUUID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
|
||||
UUID oldParent = retrievedItems[0].parentFolderID;
|
||||
|
||||
return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true;
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParent);
|
||||
IncrementFolderVersion(newParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm);
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString()));
|
||||
cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture));
|
||||
cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString()));
|
||||
cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture));
|
||||
|
||||
return DoQuery(cmd);
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
IDataReader reader;
|
||||
|
||||
cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm);
|
||||
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString()));
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm);
|
||||
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString()));
|
||||
|
||||
IDataReader reader = ExecuteReader(cmd, m_Connection);
|
||||
reader = ExecuteReader(cmd, m_Connection);
|
||||
}
|
||||
|
||||
int perms = 0;
|
||||
|
||||
@@ -177,4 +244,81 @@ namespace OpenSim.Data.SQLite
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SqliteFolderHandler : SqliteInventoryHandler<XInventoryFolder>
|
||||
{
|
||||
public SqliteFolderHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryFolder folder)
|
||||
{
|
||||
if (!base.Store(folder))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(folder.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParentFolderID)
|
||||
{
|
||||
XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
|
||||
|
||||
if (folders.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParentFolderUUID = folders[0].parentFolderID;
|
||||
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm);
|
||||
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID));
|
||||
cmd.Parameters.Add(new SqliteParameter(":FolderID", id));
|
||||
|
||||
if (ExecuteNonQuery(cmd, m_Connection) == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParentFolderUUID);
|
||||
IncrementFolderVersion(newParentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new()
|
||||
{
|
||||
public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {}
|
||||
|
||||
protected bool IncrementFolderVersion(UUID folderID)
|
||||
{
|
||||
return IncrementFolderVersion(folderID.ToString());
|
||||
}
|
||||
|
||||
protected bool IncrementFolderVersion(string folderID)
|
||||
{
|
||||
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
|
||||
// Util.PrintCallStack();
|
||||
|
||||
using (SqliteCommand cmd = new SqliteCommand())
|
||||
{
|
||||
cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
|
||||
cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ using OpenSim.Data.SQLite;
|
||||
namespace OpenSim.Data.Tests
|
||||
{
|
||||
[TestFixture(Description = "Asset store tests (SQLite)")]
|
||||
public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData>
|
||||
public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData>
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ using NUnit.Framework;
|
||||
using NUnit.Framework.Constraints;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
using log4net;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
@@ -43,6 +44,12 @@ namespace OpenSim.Data.Tests
|
||||
/// <summary>This is a base class for testing any Data service for any DBMS.
|
||||
/// Requires NUnit 2.5 or better (to support the generics).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// FIXME: Should extend OpenSimTestCase but compile on mono 2.4.3 currently fails with
|
||||
/// AssetTests`2 : System.MemberAccessException : Cannot create an instance of OpenSim.Data.Tests.AssetTests`2[TConn,TAssetData] because Type.ContainsGenericParameters is true.
|
||||
/// and similar on EstateTests, InventoryTests and RegionTests.
|
||||
/// Runs fine with mono 2.10.8.1, so easiest thing is to wait until min Mono version uplifts.
|
||||
/// </remarks>
|
||||
/// <typeparam name="TConn"></typeparam>
|
||||
/// <typeparam name="TService"></typeparam>
|
||||
public class BasicDataServiceTest<TConn, TService>
|
||||
|
||||
@@ -36,6 +36,7 @@ using NUnit.Framework;
|
||||
using NUnit.Framework.Constraints;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Data.Tests
|
||||
{
|
||||
@@ -254,7 +255,7 @@ namespace OpenSim.Data.Tests
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class PropertyCompareConstraintTest
|
||||
public class PropertyCompareConstraintTest : OpenSimTestCase
|
||||
{
|
||||
public class HasInt
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Data.Tests
|
||||
{
|
||||
@@ -158,7 +159,7 @@ namespace OpenSim.Data.Tests
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class PropertyScramblerTests
|
||||
public class PropertyScramblerTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestScramble()
|
||||
|
||||
@@ -330,6 +330,9 @@ namespace OpenSim.Framework
|
||||
SetVisualParams(visualParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set avatar height by a calculation based on their visual parameters.
|
||||
/// </summary>
|
||||
public virtual void SetHeight()
|
||||
{
|
||||
// Start with shortest possible female avatar height
|
||||
|
||||
@@ -199,7 +199,14 @@ namespace OpenSim.Framework
|
||||
//
|
||||
public class Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Must only be accessed under lock.
|
||||
/// </summary>
|
||||
private List<CacheItemBase> m_Index = new List<CacheItemBase>();
|
||||
|
||||
/// <summary>
|
||||
/// Must only be accessed under m_Index lock.
|
||||
/// </summary>
|
||||
private Dictionary<string, CacheItemBase> m_Lookup =
|
||||
new Dictionary<string, CacheItemBase>();
|
||||
|
||||
@@ -320,19 +327,19 @@ namespace OpenSim.Framework
|
||||
{
|
||||
if (m_Lookup.ContainsKey(index))
|
||||
item = m_Lookup[index];
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
Expire(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
item.hits++;
|
||||
item.lastUsed = DateTime.Now;
|
||||
|
||||
Expire(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
item.hits++;
|
||||
item.lastUsed = DateTime.Now;
|
||||
|
||||
Expire(true);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -385,7 +392,10 @@ namespace OpenSim.Framework
|
||||
//
|
||||
public Object Find(Predicate<CacheItemBase> d)
|
||||
{
|
||||
CacheItemBase item = m_Index.Find(d);
|
||||
CacheItemBase item;
|
||||
|
||||
lock (m_Index)
|
||||
item = m_Index.Find(d);
|
||||
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -419,12 +429,12 @@ namespace OpenSim.Framework
|
||||
public virtual void Store(string index, Object data, Type container,
|
||||
Object[] parameters)
|
||||
{
|
||||
Expire(false);
|
||||
|
||||
CacheItemBase item;
|
||||
|
||||
lock (m_Index)
|
||||
{
|
||||
Expire(false);
|
||||
|
||||
if (m_Index.Contains(new CacheItemBase(index)))
|
||||
{
|
||||
if ((m_Flags & CacheFlags.AllowUpdate) != 0)
|
||||
@@ -450,9 +460,17 @@ namespace OpenSim.Framework
|
||||
m_Index.Add(item);
|
||||
m_Lookup[index] = item;
|
||||
}
|
||||
|
||||
item.Store(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expire items as appropriate.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Callers must lock m_Index.
|
||||
/// </remarks>
|
||||
/// <param name='getting'></param>
|
||||
protected virtual void Expire(bool getting)
|
||||
{
|
||||
if (getting && (m_Strategy == CacheStrategy.Aggressive))
|
||||
@@ -475,12 +493,10 @@ namespace OpenSim.Framework
|
||||
|
||||
switch (m_Strategy)
|
||||
{
|
||||
case CacheStrategy.Aggressive:
|
||||
if (Count < Size)
|
||||
return;
|
||||
case CacheStrategy.Aggressive:
|
||||
if (Count < Size)
|
||||
return;
|
||||
|
||||
lock (m_Index)
|
||||
{
|
||||
m_Index.Sort(new SortLRU());
|
||||
m_Index.Reverse();
|
||||
|
||||
@@ -490,7 +506,7 @@ namespace OpenSim.Framework
|
||||
|
||||
ExpireDelegate doExpire = OnExpire;
|
||||
|
||||
if (doExpire != null)
|
||||
if (doExpire != null)
|
||||
{
|
||||
List<CacheItemBase> candidates =
|
||||
m_Index.GetRange(target, Count - target);
|
||||
@@ -513,27 +529,34 @@ namespace OpenSim.Framework
|
||||
foreach (CacheItemBase item in m_Index)
|
||||
m_Lookup[item.uuid] = item;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Invalidate(string uuid)
|
||||
{
|
||||
if (!m_Lookup.ContainsKey(uuid))
|
||||
return;
|
||||
lock (m_Index)
|
||||
{
|
||||
if (!m_Lookup.ContainsKey(uuid))
|
||||
return;
|
||||
|
||||
CacheItemBase item = m_Lookup[uuid];
|
||||
m_Lookup.Remove(uuid);
|
||||
m_Index.Remove(item);
|
||||
CacheItemBase item = m_Lookup[uuid];
|
||||
m_Lookup.Remove(uuid);
|
||||
m_Index.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_Index.Clear();
|
||||
m_Lookup.Clear();
|
||||
lock (m_Index)
|
||||
{
|
||||
m_Index.Clear();
|
||||
m_Lookup.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,8 @@ namespace OpenSim.Framework.Client
|
||||
{
|
||||
event ChatMessage OnChatFromClient;
|
||||
|
||||
void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source,
|
||||
byte audible);
|
||||
void SendChatMessage(
|
||||
string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source,
|
||||
byte audible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,8 @@ namespace OpenSim.Framework.Console
|
||||
= "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n";
|
||||
|
||||
public const string ItemHelpText
|
||||
= "For more information, type 'help <item>' where <item> is one of the following:";
|
||||
= @"For more information, type 'help all' to get a list of all commands,
|
||||
or type help <item>' where <item> is one of the following:";
|
||||
|
||||
/// <value>
|
||||
/// Commands organized by keyword in a tree
|
||||
@@ -109,19 +110,48 @@ namespace OpenSim.Framework.Console
|
||||
// Remove initial help keyword
|
||||
helpParts.RemoveAt(0);
|
||||
|
||||
help.Add(""); // Will become a newline.
|
||||
|
||||
// General help
|
||||
if (helpParts.Count == 0)
|
||||
{
|
||||
help.Add(""); // Will become a newline.
|
||||
help.Add(GeneralHelpText);
|
||||
help.Add(ItemHelpText);
|
||||
help.AddRange(CollectModulesHelp(tree));
|
||||
}
|
||||
else if (helpParts.Count == 1 && helpParts[0] == "all")
|
||||
{
|
||||
help.AddRange(CollectAllCommandsHelp());
|
||||
}
|
||||
else
|
||||
{
|
||||
help.AddRange(CollectHelp(helpParts));
|
||||
}
|
||||
|
||||
help.Add(""); // Will become a newline.
|
||||
|
||||
return help;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collects the help from all commands and return in alphabetical order.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<string> CollectAllCommandsHelp()
|
||||
{
|
||||
List<string> help = new List<string>();
|
||||
|
||||
lock (m_modulesCommands)
|
||||
{
|
||||
foreach (List<CommandInfo> commands in m_modulesCommands.Values)
|
||||
{
|
||||
var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help));
|
||||
help.AddRange(ourHelpText);
|
||||
}
|
||||
}
|
||||
|
||||
help.Sort();
|
||||
|
||||
return help;
|
||||
}
|
||||
|
||||
@@ -167,14 +197,11 @@ namespace OpenSim.Framework.Console
|
||||
|
||||
string descriptiveHelp = commandInfo.descriptive_help;
|
||||
|
||||
// If we do have some descriptive help then insert a spacing line before and after for readability.
|
||||
// If we do have some descriptive help then insert a spacing line before for readability.
|
||||
if (descriptiveHelp != string.Empty)
|
||||
help.Add(string.Empty);
|
||||
|
||||
help.Add(commandInfo.descriptive_help);
|
||||
|
||||
if (descriptiveHelp != string.Empty)
|
||||
help.Add(string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -702,7 +729,7 @@ namespace OpenSim.Framework.Console
|
||||
/// </summary>
|
||||
public void Prompt()
|
||||
{
|
||||
string line = ReadLine(m_defaultPrompt + "# ", true, true);
|
||||
string line = ReadLine(DefaultPrompt + "# ", true, true);
|
||||
|
||||
if (line != String.Empty)
|
||||
Output("Invalid command");
|
||||
|
||||
@@ -43,15 +43,7 @@ namespace OpenSim.Framework.Console
|
||||
|
||||
public object ConsoleScene { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The default prompt text.
|
||||
/// </summary>
|
||||
public string DefaultPrompt
|
||||
{
|
||||
set { m_defaultPrompt = value; }
|
||||
get { return m_defaultPrompt; }
|
||||
}
|
||||
protected string m_defaultPrompt;
|
||||
public string DefaultPrompt { get; set; }
|
||||
|
||||
public ConsoleBase(string defaultPrompt)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console
|
||||
public List<ConsoleDisplayTableRow> Rows { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of spaces to indent the table.
|
||||
/// Number of spaces to indent the whole table.
|
||||
/// </summary>
|
||||
public int Indent { get; set; }
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenSim.Framework.Console
|
||||
Columns.Add(new ConsoleDisplayTableColumn(name, width));
|
||||
}
|
||||
|
||||
public void AddRow(params string[] cells)
|
||||
public void AddRow(params object[] cells)
|
||||
{
|
||||
Rows.Add(new ConsoleDisplayTableRow(cells));
|
||||
}
|
||||
@@ -113,7 +113,8 @@ namespace OpenSim.Framework.Console
|
||||
|
||||
for (int i = 0; i < Columns.Count; i++)
|
||||
{
|
||||
formatSb.Append(' ', TableSpacing);
|
||||
if (i != 0)
|
||||
formatSb.Append(' ', TableSpacing);
|
||||
|
||||
// Can only do left formatting for now
|
||||
formatSb.AppendFormat("{{{0},-{1}}}", i, Columns[i].Width);
|
||||
@@ -139,16 +140,16 @@ namespace OpenSim.Framework.Console
|
||||
|
||||
public struct ConsoleDisplayTableRow
|
||||
{
|
||||
public List<string> Cells { get; private set; }
|
||||
public List<object> Cells { get; private set; }
|
||||
|
||||
public ConsoleDisplayTableRow(List<string> cells) : this()
|
||||
public ConsoleDisplayTableRow(List<object> cells) : this()
|
||||
{
|
||||
Cells = cells;
|
||||
}
|
||||
|
||||
public ConsoleDisplayTableRow(params string[] cells) : this()
|
||||
public ConsoleDisplayTableRow(params object[] cells) : this()
|
||||
{
|
||||
Cells = new List<string>(cells);
|
||||
Cells = new List<object>(cells);
|
||||
}
|
||||
}
|
||||
}
|
||||
229
OpenSim/Framework/Console/ConsoleUtil.cs
Normal file
229
OpenSim/Framework/Console/ConsoleUtil.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Framework.Console
|
||||
{
|
||||
public class ConsoleUtil
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public const int LocalIdNotFound = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
|
||||
/// rather than in each help summary.
|
||||
/// </summary>
|
||||
public const string CoordHelp
|
||||
= @"Each component of the coord is comma separated. There must be no spaces between the commas.
|
||||
If you don't care about the z component you can simply omit it.
|
||||
If you don't care about the x or y components then you can leave them blank (though a comma is still required)
|
||||
If you want to specify the maxmimum value of a component then you can use ~ instead of a number
|
||||
If you want to specify the minimum value of a component then you can use -~ instead of a number
|
||||
e.g.
|
||||
delete object pos 20,20,20 to 40,40,40
|
||||
delete object pos 20,20 to 40,40
|
||||
delete object pos ,20,20 to ,40,40
|
||||
delete object pos ,,30 to ,,~
|
||||
delete object pos ,,-~ to ,,30";
|
||||
|
||||
public const string MinRawConsoleVectorValue = "-~";
|
||||
public const string MaxRawConsoleVectorValue = "~";
|
||||
|
||||
public const string VectorSeparator = ",";
|
||||
public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
|
||||
|
||||
/// <summary>
|
||||
/// Try to parse a console UUID from the console.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Will complain to the console if parsing fails.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='console'>If null then no complaint is printed.</param>
|
||||
/// <param name='rawUuid'></param>
|
||||
/// <param name='uuid'></param>
|
||||
public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
|
||||
{
|
||||
if (!UUID.TryParse(rawUuid, out uuid))
|
||||
{
|
||||
if (console != null)
|
||||
console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId)
|
||||
{
|
||||
if (!uint.TryParse(rawLocalId, out localId))
|
||||
{
|
||||
if (console != null)
|
||||
console.OutputFormat("ERROR: {0} is not a valid local id", localId);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (localId == 0)
|
||||
{
|
||||
if (console != null)
|
||||
console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to parse the input as either a UUID or a local ID.
|
||||
/// </summary>
|
||||
/// <returns>true if parsing succeeded, false otherwise.</returns>
|
||||
/// <param name='console'></param>
|
||||
/// <param name='rawId'></param>
|
||||
/// <param name='uuid'></param>
|
||||
/// <param name='localId'>
|
||||
/// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded.
|
||||
/// </param>
|
||||
public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId)
|
||||
{
|
||||
if (TryParseConsoleUuid(null, rawId, out uuid))
|
||||
{
|
||||
localId = LocalIdNotFound;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TryParseConsoleLocalId(null, rawId, out localId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (console != null)
|
||||
console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
|
||||
/// </summary>
|
||||
/// <param name='console'>Can be null if no console is available.</param>
|
||||
/// <param name='rawConsoleVector'>/param>
|
||||
/// <param name='vector'></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i)
|
||||
{
|
||||
if (!int.TryParse(rawConsoleInt, out i))
|
||||
{
|
||||
if (console != null)
|
||||
console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
|
||||
/// </summary>
|
||||
/// <param name='rawConsoleVector'>/param>
|
||||
/// <param name='vector'></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
|
||||
{
|
||||
return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
|
||||
/// </summary>
|
||||
/// <param name='rawConsoleVector'>/param>
|
||||
/// <param name='vector'></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
|
||||
{
|
||||
return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a vector input from the console to an OpenMetaverse.Vector3
|
||||
/// </summary>
|
||||
/// <param name='rawConsoleVector'>
|
||||
/// A string in the form <x>,<y>,<z> where there is no space between values.
|
||||
/// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
|
||||
/// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
|
||||
/// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
|
||||
/// Other than that, component values must be numeric.
|
||||
/// </param>
|
||||
/// <param name='blankComponentFunc'></param>
|
||||
/// <param name='vector'></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryParseConsoleVector(
|
||||
string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector)
|
||||
{
|
||||
List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
|
||||
|
||||
if (components.Count < 1 || components.Count > 3)
|
||||
{
|
||||
vector = Vector3.Zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = components.Count; i < 3; i++)
|
||||
components.Add("");
|
||||
|
||||
List<string> semiDigestedComponents
|
||||
= components.ConvertAll<string>(
|
||||
c =>
|
||||
{
|
||||
if (c == "")
|
||||
return blankComponentFunc.Invoke(c);
|
||||
else if (c == MaxRawConsoleVectorValue)
|
||||
return float.MaxValue.ToString();
|
||||
else if (c == MinRawConsoleVectorValue)
|
||||
return float.MinValue.ToString();
|
||||
else
|
||||
return c;
|
||||
});
|
||||
|
||||
string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
|
||||
|
||||
// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
|
||||
|
||||
return Vector3.TryParse(semiDigestedConsoleVector, out vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,13 +44,18 @@ namespace OpenSim.Framework.Console
|
||||
|
||||
public ICommands Commands { get { return m_commands; } }
|
||||
|
||||
public string DefaultPrompt { get; set; }
|
||||
|
||||
public void Prompt() {}
|
||||
|
||||
public void RunCommand(string cmd) {}
|
||||
|
||||
public string ReadLine(string p, bool isCommand, bool e) { return ""; }
|
||||
|
||||
public object ConsoleScene { get { return null; } }
|
||||
public object ConsoleScene {
|
||||
get { return null; }
|
||||
set {}
|
||||
}
|
||||
|
||||
public void Output(string text, string level) {}
|
||||
public void Output(string text) {}
|
||||
@@ -76,4 +81,4 @@ namespace OpenSim.Framework.Console
|
||||
public string[] Resolve(string[] cmd) { return null; }
|
||||
public XmlElement GetXml(XmlDocument doc) { return null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace OpenSim.Framework
|
||||
public class Constants
|
||||
{
|
||||
public const uint RegionSize = 256;
|
||||
public const uint RegionHeight = 4096;
|
||||
public const byte TerrainPatchSize = 16;
|
||||
public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f";
|
||||
|
||||
|
||||
508
OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
Normal file
508
OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
Normal file
@@ -0,0 +1,508 @@
|
||||
/*
|
||||
* Copyright (c) 2008, openmetaverse.org, http://opensimulator.org/
|
||||
* All rights reserved.
|
||||
*
|
||||
* - Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* - Neither the name of the openmetaverse.org nor the names
|
||||
* of its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// A double dictionary that is thread abort safe.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This adapts OpenMetaverse.DoubleDictionary to be thread-abort safe by acquiring ReaderWriterLockSlim within
|
||||
/// a finally section (which can't be interrupted by Thread.Abort()).
|
||||
/// </remarks>
|
||||
public class DoubleDictionaryThreadAbortSafe<TKey1, TKey2, TValue>
|
||||
{
|
||||
Dictionary<TKey1, TValue> Dictionary1;
|
||||
Dictionary<TKey2, TValue> Dictionary2;
|
||||
ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim();
|
||||
|
||||
public DoubleDictionaryThreadAbortSafe()
|
||||
{
|
||||
Dictionary1 = new Dictionary<TKey1,TValue>();
|
||||
Dictionary2 = new Dictionary<TKey2,TValue>();
|
||||
}
|
||||
|
||||
public DoubleDictionaryThreadAbortSafe(int capacity)
|
||||
{
|
||||
Dictionary1 = new Dictionary<TKey1, TValue>(capacity);
|
||||
Dictionary2 = new Dictionary<TKey2, TValue>(capacity);
|
||||
}
|
||||
|
||||
public void Add(TKey1 key1, TKey2 key2, TValue value)
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterWriteLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
if (Dictionary1.ContainsKey(key1))
|
||||
{
|
||||
if (!Dictionary2.ContainsKey(key2))
|
||||
throw new ArgumentException("key1 exists in the dictionary but not key2");
|
||||
}
|
||||
else if (Dictionary2.ContainsKey(key2))
|
||||
{
|
||||
if (!Dictionary1.ContainsKey(key1))
|
||||
throw new ArgumentException("key2 exists in the dictionary but not key1");
|
||||
}
|
||||
|
||||
Dictionary1[key1] = value;
|
||||
Dictionary2[key2] = value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(TKey1 key1, TKey2 key2)
|
||||
{
|
||||
bool success;
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterWriteLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
Dictionary1.Remove(key1);
|
||||
success = Dictionary2.Remove(key2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool Remove(TKey1 key1)
|
||||
{
|
||||
bool found = false;
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterWriteLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
// This is an O(n) operation!
|
||||
TValue value;
|
||||
if (Dictionary1.TryGetValue(key1, out value))
|
||||
{
|
||||
foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2)
|
||||
{
|
||||
if (kvp.Value.Equals(value))
|
||||
{
|
||||
Dictionary1.Remove(key1);
|
||||
Dictionary2.Remove(kvp.Key);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public bool Remove(TKey2 key2)
|
||||
{
|
||||
bool found = false;
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterWriteLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
// This is an O(n) operation!
|
||||
TValue value;
|
||||
if (Dictionary2.TryGetValue(key2, out value))
|
||||
{
|
||||
foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1)
|
||||
{
|
||||
if (kvp.Value.Equals(value))
|
||||
{
|
||||
Dictionary2.Remove(key2);
|
||||
Dictionary1.Remove(kvp.Key);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterWriteLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
Dictionary1.Clear();
|
||||
Dictionary2.Clear();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Dictionary1.Count; }
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey1 key)
|
||||
{
|
||||
return Dictionary1.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey2 key)
|
||||
{
|
||||
return Dictionary2.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey1 key, out TValue value)
|
||||
{
|
||||
bool success;
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
success = Dictionary1.TryGetValue(key, out value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey2 key, out TValue value)
|
||||
{
|
||||
bool success;
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
success = Dictionary2.TryGetValue(key, out value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public void ForEach(Action<TValue> action)
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
foreach (TValue value in Dictionary1.Values)
|
||||
action(value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public void ForEach(Action<KeyValuePair<TKey1, TValue>> action)
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1)
|
||||
action(entry);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public void ForEach(Action<KeyValuePair<TKey2, TValue>> action)
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2)
|
||||
action(entry);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public TValue FindValue(Predicate<TValue> predicate)
|
||||
{
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
foreach (TValue value in Dictionary1.Values)
|
||||
{
|
||||
if (predicate(value))
|
||||
return value;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
|
||||
return default(TValue);
|
||||
}
|
||||
|
||||
public IList<TValue> FindAll(Predicate<TValue> predicate)
|
||||
{
|
||||
IList<TValue> list = new List<TValue>();
|
||||
bool gotLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
|
||||
foreach (TValue value in Dictionary1.Values)
|
||||
{
|
||||
if (predicate(value))
|
||||
list.Add(value);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
rwLock.ExitReadLock();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public int RemoveAll(Predicate<TValue> predicate)
|
||||
{
|
||||
IList<TKey1> list = new List<TKey1>();
|
||||
bool gotUpgradeableLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
|
||||
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
|
||||
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterUpgradeableReadLock();
|
||||
gotUpgradeableLock = true;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1)
|
||||
{
|
||||
if (predicate(kvp.Value))
|
||||
list.Add(kvp.Key);
|
||||
}
|
||||
|
||||
IList<TKey2> list2 = new List<TKey2>(list.Count);
|
||||
foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2)
|
||||
{
|
||||
if (predicate(kvp.Value))
|
||||
list2.Add(kvp.Key);
|
||||
}
|
||||
|
||||
bool gotWriteLock = false;
|
||||
|
||||
try
|
||||
{
|
||||
try {}
|
||||
finally
|
||||
{
|
||||
rwLock.EnterUpgradeableReadLock();
|
||||
gotWriteLock = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
Dictionary1.Remove(list[i]);
|
||||
|
||||
for (int i = 0; i < list2.Count; i++)
|
||||
Dictionary2.Remove(list2[i]);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotWriteLock)
|
||||
rwLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotUpgradeableLock)
|
||||
rwLock.ExitUpgradeableReadLock();
|
||||
}
|
||||
|
||||
return list.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -805,8 +805,23 @@ namespace OpenSim.Framework
|
||||
event Action<IClientAPI> OnRegionHandShakeReply;
|
||||
event GenericCall1 OnRequestWearables;
|
||||
event Action<IClientAPI, bool> OnCompleteMovementToRegion;
|
||||
|
||||
/// <summary>
|
||||
/// Called when an AgentUpdate message is received and before OnAgentUpdate.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates.
|
||||
/// </remarks>
|
||||
event UpdateAgent OnPreAgentUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Called when an AgentUpdate message is received and after OnPreAgentUpdate.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates.
|
||||
/// </remarks>
|
||||
event UpdateAgent OnAgentUpdate;
|
||||
|
||||
event AgentRequestSit OnAgentRequestSit;
|
||||
event AgentSit OnAgentSit;
|
||||
event AvatarPickerRequest OnAvatarPickerRequest;
|
||||
@@ -1033,7 +1048,21 @@ namespace OpenSim.Framework
|
||||
|
||||
void InPacket(object NewPack);
|
||||
void ProcessInPacket(Packet NewPack);
|
||||
|
||||
/// <summary>
|
||||
/// Close this client
|
||||
/// </summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Close this client
|
||||
/// </summary>
|
||||
/// <param name='force'>
|
||||
/// If true, attempts the close without checking active status. You do not want to try this except as a last
|
||||
/// ditch attempt where Active == false but the ScenePresence still exists.
|
||||
/// </param>
|
||||
void Close(bool force);
|
||||
|
||||
void Kick(string message);
|
||||
|
||||
/// <summary>
|
||||
@@ -1070,8 +1099,20 @@ namespace OpenSim.Framework
|
||||
void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs);
|
||||
void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args);
|
||||
|
||||
void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source,
|
||||
byte audible);
|
||||
/// <summary>
|
||||
/// Send chat to the viewer.
|
||||
/// </summary>
|
||||
/// <param name='message'></param>
|
||||
/// <param name='type'></param>
|
||||
/// <param name='fromPos'></param>
|
||||
/// <param name='fromName'></param>
|
||||
/// <param name='fromAgentID'></param>
|
||||
/// <param name='ownerID'></param>
|
||||
/// <param name='source'></param>
|
||||
/// <param name='audible'></param>
|
||||
void SendChatMessage(
|
||||
string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source,
|
||||
byte audible);
|
||||
|
||||
void SendInstantMessage(GridInstantMessage im);
|
||||
|
||||
|
||||
@@ -78,6 +78,11 @@ namespace OpenSim.Framework
|
||||
{
|
||||
ICommands Commands { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The default prompt text.
|
||||
/// </summary>
|
||||
string DefaultPrompt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display a command prompt on the console and wait for user input
|
||||
/// </summary>
|
||||
@@ -87,4 +92,4 @@ namespace OpenSim.Framework
|
||||
|
||||
string ReadLine(string p, bool isCommand, bool e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenSim.Framework
|
||||
{
|
||||
public interface IConsole
|
||||
{
|
||||
object ConsoleScene { get; }
|
||||
object ConsoleScene { get; set; }
|
||||
|
||||
void Output(string text, string level);
|
||||
void Output(string text);
|
||||
|
||||
@@ -73,33 +73,27 @@ namespace OpenSim.Framework
|
||||
{
|
||||
}
|
||||
|
||||
public InventoryFolderBase(UUID id)
|
||||
public InventoryFolderBase(UUID id) : this()
|
||||
{
|
||||
ID = id;
|
||||
}
|
||||
|
||||
public InventoryFolderBase(UUID id, UUID owner)
|
||||
public InventoryFolderBase(UUID id, UUID owner) : this(id)
|
||||
{
|
||||
ID = id;
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent)
|
||||
public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) : this(id, owner)
|
||||
{
|
||||
ID = id;
|
||||
Name = name;
|
||||
Owner = owner;
|
||||
ParentID = parent;
|
||||
}
|
||||
|
||||
public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version)
|
||||
public InventoryFolderBase(
|
||||
UUID id, string name, UUID owner, short type, UUID parent, ushort version) : this(id, name, owner, parent)
|
||||
{
|
||||
ID = id;
|
||||
Name = name;
|
||||
Owner = owner;
|
||||
Type = type;
|
||||
ParentID = parent;
|
||||
Version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,16 +87,7 @@ namespace OpenSim.Framework
|
||||
protected string m_creatorId;
|
||||
|
||||
/// <value>
|
||||
/// The UUID for the creator. This may be different from the canonical CreatorId. This property is used
|
||||
/// for communication with the client over the Second Life protocol, since that protocol can only understand
|
||||
/// UUIDs. As this is a basic framework class, this means that both the string creator id and the uuid
|
||||
/// reference have to be settable separately
|
||||
///
|
||||
/// Database plugins don't need to set this, it will be set by
|
||||
/// upstream code (or set by the get accessor if left unset).
|
||||
///
|
||||
/// XXX: An alternative to having a separate uuid property would be to hash the CreatorId appropriately
|
||||
/// every time there was communication with a UUID-only client. This may be much more expensive.
|
||||
/// The CreatorId expressed as a UUID.tely
|
||||
/// </value>
|
||||
public UUID CreatorIdAsUuid
|
||||
{
|
||||
@@ -109,20 +100,18 @@ namespace OpenSim.Framework
|
||||
|
||||
return m_creatorIdAsUuid;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_creatorIdAsUuid = value;
|
||||
}
|
||||
}
|
||||
protected UUID m_creatorIdAsUuid = UUID.Zero;
|
||||
|
||||
protected string m_creatorData = string.Empty;
|
||||
/// <summary>
|
||||
/// Extended creator information of the form <profile url>;<name>
|
||||
/// </summary>
|
||||
public string CreatorData // = <profile url>;<name>
|
||||
{
|
||||
get { return m_creatorData; }
|
||||
set { m_creatorData = value; }
|
||||
}
|
||||
protected string m_creatorData = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Used by the DB layer to retrieve / store the entire user identification.
|
||||
@@ -162,7 +151,6 @@ namespace OpenSim.Framework
|
||||
name = parts[2];
|
||||
|
||||
m_creatorData += ';' + name;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,11 @@ namespace OpenSim.Framework.Monitoring
|
||||
Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
|
||||
|
||||
sb.AppendFormat(
|
||||
"OpenSim object memory churn : {0} MB/s\n",
|
||||
"OpenSim last object memory churn : {0} MB/s\n",
|
||||
Math.Round((MemoryWatchdog.LastMemoryChurn * 1000) / 1024.0 / 1024, 3));
|
||||
|
||||
sb.AppendFormat(
|
||||
"OpenSim average object memory churn : {0} MB/s\n",
|
||||
Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3));
|
||||
|
||||
sb.AppendFormat(
|
||||
|
||||
@@ -60,13 +60,21 @@ namespace OpenSim.Framework.Monitoring
|
||||
private static bool m_enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Average memory churn in bytes per millisecond.
|
||||
/// Last memory churn in bytes per millisecond.
|
||||
/// </summary>
|
||||
public static double AverageMemoryChurn
|
||||
{
|
||||
get { if (m_samples.Count > 0) return m_samples.Average(); else return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Average memory churn in bytes per millisecond.
|
||||
/// </summary>
|
||||
public static double LastMemoryChurn
|
||||
{
|
||||
get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of statistical samples.
|
||||
/// </summary>
|
||||
|
||||
@@ -355,10 +355,25 @@ Asset service request failures: {3}" + Environment.NewLine,
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.Append(
|
||||
string.Format(
|
||||
"{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}",
|
||||
"{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n",
|
||||
inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
|
||||
netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
Dictionary<string, Dictionary<string, Stat>> sceneStats;
|
||||
|
||||
if (StatsManager.TryGetStats("scene", out sceneStats))
|
||||
{
|
||||
foreach (KeyValuePair<string, Dictionary<string, Stat>> kvp in sceneStats)
|
||||
{
|
||||
foreach (Stat stat in kvp.Value.Values)
|
||||
{
|
||||
if (stat.Verbosity == StatVerbosity.Info)
|
||||
{
|
||||
sb.AppendFormat("{0} ({1}): {2}{3}\n", stat.Name, stat.Container, stat.Value, stat.UnitName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
88
OpenSim/Framework/Monitoring/Stats/PercentageStat.cs
Normal file
88
OpenSim/Framework/Monitoring/Stats/PercentageStat.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
public class PercentageStat : Stat
|
||||
{
|
||||
public long Antecedent { get; set; }
|
||||
public long Consequent { get; set; }
|
||||
|
||||
public override double Value
|
||||
{
|
||||
get
|
||||
{
|
||||
// Asking for an update here means that the updater cannot access this value without infinite recursion.
|
||||
// XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
|
||||
// called by the pull action and just return the value.
|
||||
if (StatType == StatType.Pull)
|
||||
PullAction(this);
|
||||
|
||||
long c = Consequent;
|
||||
|
||||
// Avoid any chance of a multi-threaded divide-by-zero
|
||||
if (c == 0)
|
||||
return 0;
|
||||
|
||||
return (double)Antecedent / c * 100;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new InvalidOperationException("Cannot set value on a PercentageStat");
|
||||
}
|
||||
}
|
||||
|
||||
public PercentageStat(
|
||||
string shortName,
|
||||
string name,
|
||||
string description,
|
||||
string category,
|
||||
string container,
|
||||
StatType type,
|
||||
Action<Stat> pullAction,
|
||||
StatVerbosity verbosity)
|
||||
: base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {}
|
||||
|
||||
public override string ToConsoleString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendFormat(
|
||||
"{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})",
|
||||
Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
|
||||
|
||||
AppendMeasuresOfInterest(sb);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
238
OpenSim/Framework/Monitoring/Stats/Stat.cs
Normal file
238
OpenSim/Framework/Monitoring/Stats/Stat.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds individual statistic details
|
||||
/// </summary>
|
||||
public class Stat
|
||||
{
|
||||
/// <summary>
|
||||
/// Category of this stat (e.g. cache, scene, etc).
|
||||
/// </summary>
|
||||
public string Category { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Containing name for this stat.
|
||||
/// FIXME: In the case of a scene, this is currently the scene name (though this leaves
|
||||
/// us with a to-be-resolved problem of non-unique region names).
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The container.
|
||||
/// </value>
|
||||
public string Container { get; private set; }
|
||||
|
||||
public StatType StatType { get; private set; }
|
||||
|
||||
public MeasuresOfInterest MeasuresOfInterest { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Action used to update this stat when the value is requested if it's a pull type.
|
||||
/// </summary>
|
||||
public Action<Stat> PullAction { get; private set; }
|
||||
|
||||
public StatVerbosity Verbosity { get; private set; }
|
||||
public string ShortName { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public virtual string UnitName { get; private set; }
|
||||
|
||||
public virtual double Value
|
||||
{
|
||||
get
|
||||
{
|
||||
// Asking for an update here means that the updater cannot access this value without infinite recursion.
|
||||
// XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
|
||||
// called by the pull action and just return the value.
|
||||
if (StatType == StatType.Pull)
|
||||
PullAction(this);
|
||||
|
||||
return m_value;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private double m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Historical samples for calculating measures of interest average.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Will be null if no measures of interest require samples.
|
||||
/// </remarks>
|
||||
private static Queue<double> m_samples;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of statistical samples.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from
|
||||
/// the main Watchdog.
|
||||
/// </remarks>
|
||||
private static int m_maxSamples = 24;
|
||||
|
||||
public Stat(
|
||||
string shortName,
|
||||
string name,
|
||||
string description,
|
||||
string unitName,
|
||||
string category,
|
||||
string container,
|
||||
StatType type,
|
||||
Action<Stat> pullAction,
|
||||
StatVerbosity verbosity)
|
||||
: this(
|
||||
shortName,
|
||||
name,
|
||||
description,
|
||||
unitName,
|
||||
category,
|
||||
container,
|
||||
type,
|
||||
MeasuresOfInterest.None,
|
||||
pullAction,
|
||||
verbosity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param>
|
||||
/// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param>
|
||||
/// <param name='description'>Description of stat</param>
|
||||
/// <param name='unitName'>
|
||||
/// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value.
|
||||
/// e.g. " frames"
|
||||
/// </param>
|
||||
/// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param>
|
||||
/// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param>
|
||||
/// <param name='type'>Push or pull</param>
|
||||
/// <param name='pullAction'>Pull stats need an action to update the stat on request. Push stats should set null here.</param>
|
||||
/// <param name='moi'>Measures of interest</param>
|
||||
/// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param>
|
||||
public Stat(
|
||||
string shortName,
|
||||
string name,
|
||||
string description,
|
||||
string unitName,
|
||||
string category,
|
||||
string container,
|
||||
StatType type,
|
||||
MeasuresOfInterest moi,
|
||||
Action<Stat> pullAction,
|
||||
StatVerbosity verbosity)
|
||||
{
|
||||
if (StatsManager.SubCommands.Contains(category))
|
||||
throw new Exception(
|
||||
string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category));
|
||||
|
||||
ShortName = shortName;
|
||||
Name = name;
|
||||
Description = description;
|
||||
UnitName = unitName;
|
||||
Category = category;
|
||||
Container = container;
|
||||
StatType = type;
|
||||
|
||||
if (StatType == StatType.Push && pullAction != null)
|
||||
throw new Exception("A push stat cannot have a pull action");
|
||||
else
|
||||
PullAction = pullAction;
|
||||
|
||||
MeasuresOfInterest = moi;
|
||||
|
||||
if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime)
|
||||
m_samples = new Queue<double>(m_maxSamples);
|
||||
|
||||
Verbosity = verbosity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record a value in the sample set.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Do not call this if MeasuresOfInterest.None
|
||||
/// </remarks>
|
||||
public void RecordValue()
|
||||
{
|
||||
double newValue = Value;
|
||||
|
||||
lock (m_samples)
|
||||
{
|
||||
if (m_samples.Count >= m_maxSamples)
|
||||
m_samples.Dequeue();
|
||||
|
||||
m_samples.Enqueue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string ToConsoleString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName);
|
||||
|
||||
AppendMeasuresOfInterest(sb);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected void AppendMeasuresOfInterest(StringBuilder sb)
|
||||
{
|
||||
if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime)
|
||||
== MeasuresOfInterest.AverageChangeOverTime)
|
||||
{
|
||||
double totalChange = 0;
|
||||
double? lastSample = null;
|
||||
|
||||
lock (m_samples)
|
||||
{
|
||||
foreach (double s in m_samples)
|
||||
{
|
||||
if (lastSample != null)
|
||||
totalChange += s - (double)lastSample;
|
||||
|
||||
lastSample = s;
|
||||
}
|
||||
}
|
||||
|
||||
int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1;
|
||||
|
||||
sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,10 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
@@ -32,6 +36,24 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// </summary>
|
||||
public class StatsManager
|
||||
{
|
||||
// Subcommand used to list other stats.
|
||||
public const string AllSubCommand = "all";
|
||||
|
||||
// Subcommand used to list other stats.
|
||||
public const string ListSubCommand = "list";
|
||||
|
||||
// All subcommands
|
||||
public static HashSet<string> SubCommands = new HashSet<string> { AllSubCommand, ListSubCommand };
|
||||
|
||||
/// <summary>
|
||||
/// Registered stats categorized by category/container/shortname
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Do not add or remove directly from this dictionary.
|
||||
/// </remarks>
|
||||
public static Dictionary<string, Dictionary<string, Dictionary<string, Stat>>> RegisteredStats
|
||||
= new Dictionary<string, Dictionary<string, Dictionary<string, Stat>>>();
|
||||
|
||||
private static AssetStatsCollector assetStats;
|
||||
private static UserStatsCollector userStats;
|
||||
private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector();
|
||||
@@ -40,6 +62,75 @@ namespace OpenSim.Framework.Monitoring
|
||||
public static UserStatsCollector UserStats { get { return userStats; } }
|
||||
public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } }
|
||||
|
||||
public static void RegisterConsoleCommands(ICommandConsole console)
|
||||
{
|
||||
console.Commands.AddCommand(
|
||||
"General",
|
||||
false,
|
||||
"show stats",
|
||||
"show stats [list|all|<category>]",
|
||||
"Show statistical information for this server",
|
||||
"If no final argument is specified then legacy statistics information is currently shown.\n"
|
||||
+ "If list is specified then statistic categories are shown.\n"
|
||||
+ "If all is specified then all registered statistics are shown.\n"
|
||||
+ "If a category name is specified then only statistics from that category are shown.\n"
|
||||
+ "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
|
||||
HandleShowStatsCommand);
|
||||
}
|
||||
|
||||
public static void HandleShowStatsCommand(string module, string[] cmd)
|
||||
{
|
||||
ICommandConsole con = MainConsole.Instance;
|
||||
|
||||
if (cmd.Length > 2)
|
||||
{
|
||||
var categoryName = cmd[2];
|
||||
|
||||
if (categoryName == AllSubCommand)
|
||||
{
|
||||
foreach (var category in RegisteredStats.Values)
|
||||
{
|
||||
OutputCategoryStatsToConsole(con, category);
|
||||
}
|
||||
}
|
||||
else if (categoryName == ListSubCommand)
|
||||
{
|
||||
con.Output("Statistic categories available are:");
|
||||
foreach (string category in RegisteredStats.Keys)
|
||||
con.OutputFormat(" {0}", category);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, Dictionary<string, Stat>> category;
|
||||
if (!RegisteredStats.TryGetValue(categoryName, out category))
|
||||
{
|
||||
con.OutputFormat("No such category as {0}", categoryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputCategoryStatsToConsole(con, category);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy
|
||||
con.Output(SimExtraStats.Report());
|
||||
}
|
||||
}
|
||||
|
||||
private static void OutputCategoryStatsToConsole(
|
||||
ICommandConsole con, Dictionary<string, Dictionary<string, Stat>> category)
|
||||
{
|
||||
foreach (var container in category.Values)
|
||||
{
|
||||
foreach (Stat stat in container.Values)
|
||||
{
|
||||
con.Output(stat.ToConsoleString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start collecting statistics related to assets.
|
||||
/// Should only be called once.
|
||||
@@ -61,5 +152,153 @@ namespace OpenSim.Framework.Monitoring
|
||||
|
||||
return userStats;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a statistic.
|
||||
/// </summary>
|
||||
/// <param name='stat'></param>
|
||||
/// <returns></returns>
|
||||
public static bool RegisterStat(Stat stat)
|
||||
{
|
||||
Dictionary<string, Dictionary<string, Stat>> category = null, newCategory;
|
||||
Dictionary<string, Stat> container = null, newContainer;
|
||||
|
||||
lock (RegisteredStats)
|
||||
{
|
||||
// Stat name is not unique across category/container/shortname key.
|
||||
// XXX: For now just return false. This is to avoid problems in regression tests where all tests
|
||||
// in a class are run in the same instance of the VM.
|
||||
if (TryGetStat(stat, out category, out container))
|
||||
return false;
|
||||
|
||||
// We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
|
||||
// This means that we don't need to lock or copy them on iteration, which will be a much more
|
||||
// common operation after startup.
|
||||
if (container != null)
|
||||
newContainer = new Dictionary<string, Stat>(container);
|
||||
else
|
||||
newContainer = new Dictionary<string, Stat>();
|
||||
|
||||
if (category != null)
|
||||
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
|
||||
else
|
||||
newCategory = new Dictionary<string, Dictionary<string, Stat>>();
|
||||
|
||||
newContainer[stat.ShortName] = stat;
|
||||
newCategory[stat.Container] = newContainer;
|
||||
RegisteredStats[stat.Category] = newCategory;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deregister a statistic
|
||||
/// </summary>>
|
||||
/// <param name='stat'></param>
|
||||
/// <returns></returns
|
||||
public static bool DeregisterStat(Stat stat)
|
||||
{
|
||||
Dictionary<string, Dictionary<string, Stat>> category = null, newCategory;
|
||||
Dictionary<string, Stat> container = null, newContainer;
|
||||
|
||||
lock (RegisteredStats)
|
||||
{
|
||||
if (!TryGetStat(stat, out category, out container))
|
||||
return false;
|
||||
|
||||
newContainer = new Dictionary<string, Stat>(container);
|
||||
newContainer.Remove(stat.ShortName);
|
||||
|
||||
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
|
||||
newCategory.Remove(stat.Container);
|
||||
|
||||
newCategory[stat.Container] = newContainer;
|
||||
RegisteredStats[stat.Category] = newCategory;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetStats(string category, out Dictionary<string, Dictionary<string, Stat>> stats)
|
||||
{
|
||||
return RegisteredStats.TryGetValue(category, out stats);
|
||||
}
|
||||
|
||||
public static bool TryGetStat(
|
||||
Stat stat,
|
||||
out Dictionary<string, Dictionary<string, Stat>> category,
|
||||
out Dictionary<string, Stat> container)
|
||||
{
|
||||
category = null;
|
||||
container = null;
|
||||
|
||||
lock (RegisteredStats)
|
||||
{
|
||||
if (RegisteredStats.TryGetValue(stat.Category, out category))
|
||||
{
|
||||
if (category.TryGetValue(stat.Container, out container))
|
||||
{
|
||||
if (container.ContainsKey(stat.ShortName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void RecordStats()
|
||||
{
|
||||
lock (RegisteredStats)
|
||||
{
|
||||
foreach (Dictionary<string, Dictionary<string, Stat>> category in RegisteredStats.Values)
|
||||
{
|
||||
foreach (Dictionary<string, Stat> container in category.Values)
|
||||
{
|
||||
foreach (Stat stat in container.Values)
|
||||
{
|
||||
if (stat.MeasuresOfInterest != MeasuresOfInterest.None)
|
||||
stat.RecordValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stat type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A push stat is one which is continually updated and so it's value can simply by read.
|
||||
/// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated.
|
||||
/// </remarks>
|
||||
public enum StatType
|
||||
{
|
||||
Push,
|
||||
Pull
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures of interest for this stat.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MeasuresOfInterest
|
||||
{
|
||||
None,
|
||||
AverageChangeOverTime
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verbosity of stat.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Info will always be displayed.
|
||||
/// </remarks>
|
||||
public enum StatVerbosity
|
||||
{
|
||||
Debug,
|
||||
Info
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring
|
||||
public static class Watchdog
|
||||
{
|
||||
/// <summary>Timer interval in milliseconds for the watchdog timer</summary>
|
||||
const double WATCHDOG_INTERVAL_MS = 2500.0d;
|
||||
public const double WATCHDOG_INTERVAL_MS = 2500.0d;
|
||||
|
||||
/// <summary>Default timeout in milliseconds before a thread is considered dead</summary>
|
||||
public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000;
|
||||
@@ -89,6 +89,17 @@ namespace OpenSim.Framework.Monitoring
|
||||
FirstTick = Environment.TickCount & Int32.MaxValue;
|
||||
LastTick = FirstTick;
|
||||
}
|
||||
|
||||
public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi)
|
||||
{
|
||||
Thread = previousTwi.Thread;
|
||||
FirstTick = previousTwi.FirstTick;
|
||||
LastTick = previousTwi.LastTick;
|
||||
Timeout = previousTwi.Timeout;
|
||||
IsTimedOut = previousTwi.IsTimedOut;
|
||||
AlarmIfTimeout = previousTwi.AlarmIfTimeout;
|
||||
AlarmMethod = previousTwi.AlarmMethod;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,6 +108,32 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// /summary>
|
||||
public static event Action<ThreadWatchdogInfo> OnWatchdogTimeout;
|
||||
|
||||
/// <summary>
|
||||
/// Is this watchdog active?
|
||||
/// </summary>
|
||||
public static bool Enabled
|
||||
{
|
||||
get { return m_enabled; }
|
||||
set
|
||||
{
|
||||
// m_log.DebugFormat("[MEMORY WATCHDOG]: Setting MemoryWatchdog.Enabled to {0}", value);
|
||||
|
||||
if (value == m_enabled)
|
||||
return;
|
||||
|
||||
m_enabled = value;
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
// Set now so we don't get alerted on the first run
|
||||
LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
|
||||
}
|
||||
|
||||
m_watchdogTimer.Enabled = m_enabled;
|
||||
}
|
||||
}
|
||||
private static bool m_enabled;
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static Dictionary<int, ThreadWatchdogInfo> m_threads;
|
||||
private static System.Timers.Timer m_watchdogTimer;
|
||||
@@ -115,11 +152,6 @@ namespace OpenSim.Framework.Monitoring
|
||||
m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS);
|
||||
m_watchdogTimer.AutoReset = false;
|
||||
m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
|
||||
|
||||
// Set now so we don't get alerted on the first run
|
||||
LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
|
||||
|
||||
m_watchdogTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,7 +231,25 @@ namespace OpenSim.Framework.Monitoring
|
||||
private static bool RemoveThread(int threadID)
|
||||
{
|
||||
lock (m_threads)
|
||||
return m_threads.Remove(threadID);
|
||||
{
|
||||
ThreadWatchdogInfo twi;
|
||||
if (m_threads.TryGetValue(threadID, out twi))
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId);
|
||||
|
||||
m_threads.Remove(threadID);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AbortThread(int threadID)
|
||||
@@ -314,7 +364,9 @@ namespace OpenSim.Framework.Monitoring
|
||||
if (callbackInfos == null)
|
||||
callbackInfos = new List<ThreadWatchdogInfo>();
|
||||
|
||||
callbackInfos.Add(threadInfo);
|
||||
// Send a copy of the watchdog info to prevent race conditions where the watchdog
|
||||
// thread updates the monitoring info after an alarm has been sent out.
|
||||
callbackInfos.Add(new ThreadWatchdogInfo(threadInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,6 +380,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
if (MemoryWatchdog.Enabled)
|
||||
MemoryWatchdog.Update();
|
||||
|
||||
StatsManager.RecordStats();
|
||||
|
||||
m_watchdogTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
91
OpenSim/Framework/Pool.cs
Normal file
91
OpenSim/Framework/Pool.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Naive pool implementation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently assumes that objects are in a useable state when returned.
|
||||
/// </remarks>
|
||||
public class Pool<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of objects in the pool.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_pool)
|
||||
return m_pool.Count;
|
||||
}
|
||||
}
|
||||
|
||||
private Stack<T> m_pool;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum pool size. Beyond this, any returned objects are not pooled.
|
||||
/// </summary>
|
||||
private int m_maxPoolSize;
|
||||
|
||||
private Func<T> m_createFunction;
|
||||
|
||||
public Pool(Func<T> createFunction, int maxSize)
|
||||
{
|
||||
m_maxPoolSize = maxSize;
|
||||
m_createFunction = createFunction;
|
||||
m_pool = new Stack<T>(m_maxPoolSize);
|
||||
}
|
||||
|
||||
public T GetObject()
|
||||
{
|
||||
lock (m_pool)
|
||||
{
|
||||
if (m_pool.Count > 0)
|
||||
return m_pool.Pop();
|
||||
else
|
||||
return m_createFunction();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReturnObject(T obj)
|
||||
{
|
||||
lock (m_pool)
|
||||
{
|
||||
if (m_pool.Count >= m_maxPoolSize)
|
||||
return;
|
||||
else
|
||||
m_pool.Push(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,18 +192,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public PrimitiveBaseShape()
|
||||
{
|
||||
PCode = (byte) PCodeEnum.Primitive;
|
||||
ExtraParams = new byte[1];
|
||||
m_textureEntry = DEFAULT_TEXTURE;
|
||||
}
|
||||
|
||||
public PrimitiveBaseShape(bool noShape)
|
||||
{
|
||||
if (noShape)
|
||||
return;
|
||||
|
||||
PCode = (byte)PCodeEnum.Primitive;
|
||||
ExtraParams = new byte[1];
|
||||
m_textureEntry = DEFAULT_TEXTURE;
|
||||
}
|
||||
|
||||
@@ -216,7 +205,6 @@ namespace OpenSim.Framework
|
||||
// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID);
|
||||
|
||||
PCode = (byte)prim.PrimData.PCode;
|
||||
ExtraParams = new byte[1];
|
||||
|
||||
State = prim.PrimData.State;
|
||||
PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
|
||||
@@ -248,7 +236,10 @@ namespace OpenSim.Framework
|
||||
SculptTexture = prim.Sculpt.SculptTexture;
|
||||
SculptType = (byte)prim.Sculpt.Type;
|
||||
}
|
||||
else SculptType = (byte)OpenMetaverse.SculptType.None;
|
||||
else
|
||||
{
|
||||
SculptType = (byte)OpenMetaverse.SculptType.None;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
@@ -340,9 +331,9 @@ namespace OpenSim.Framework
|
||||
_scale = new Vector3(side, side, side);
|
||||
}
|
||||
|
||||
public void SetHeigth(float heigth)
|
||||
public void SetHeigth(float height)
|
||||
{
|
||||
_scale.Z = heigth;
|
||||
_scale.Z = height;
|
||||
}
|
||||
|
||||
public void SetRadius(float radius)
|
||||
|
||||
@@ -65,9 +65,14 @@ namespace OpenSim.Framework.Serialization
|
||||
|
||||
UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
|
||||
if (account != null)
|
||||
{
|
||||
return MakeOspa(account.FirstName, account.LastName);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId);
|
||||
// System.Console.WriteLine("[OSP RESOLVER]: No user account for {0}", userId);
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -79,10 +84,13 @@ namespace OpenSim.Framework.Serialization
|
||||
/// <returns></returns>
|
||||
public static string MakeOspa(string firstName, string lastName)
|
||||
{
|
||||
// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName);
|
||||
string ospa
|
||||
= OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
|
||||
|
||||
// m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
|
||||
// System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
|
||||
|
||||
return
|
||||
OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
|
||||
return ospa;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
|
||||
namespace OpenSim.Framework.Serialization.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LandDataSerializerTest
|
||||
public class LandDataSerializerTest : OpenSimTestCase
|
||||
{
|
||||
private LandData land;
|
||||
private LandData landWithParcelAccessList;
|
||||
|
||||
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
|
||||
namespace OpenSim.Framework.Serialization.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class RegionSettingsSerializerTests
|
||||
public class RegionSettingsSerializerTests : OpenSimTestCase
|
||||
{
|
||||
private string m_serializedRs = @"<?xml version=""1.0"" encoding=""utf-16""?>
|
||||
<RegionSettings>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
@@ -38,6 +37,8 @@ using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Core;
|
||||
using log4net.Repository;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
@@ -45,16 +46,12 @@ using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using Timer=System.Timers.Timer;
|
||||
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
/// <summary>
|
||||
/// Common base for the main OpenSimServers (user, grid, inventory, region, etc)
|
||||
/// </summary>
|
||||
public abstract class BaseOpenSimServer
|
||||
public abstract class BaseOpenSimServer : ServerBase
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -63,27 +60,6 @@ namespace OpenSim.Framework.Servers
|
||||
/// server.
|
||||
/// </summary>
|
||||
private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
|
||||
|
||||
protected CommandConsole m_console;
|
||||
protected OpenSimAppender m_consoleAppender;
|
||||
protected IAppender m_logFileAppender = null;
|
||||
|
||||
/// <summary>
|
||||
/// Time at which this server was started
|
||||
/// </summary>
|
||||
protected DateTime m_startuptime;
|
||||
|
||||
/// <summary>
|
||||
/// Record the initial startup directory for info purposes
|
||||
/// </summary>
|
||||
protected string m_startupDirectory = Environment.CurrentDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
|
||||
/// </summary>
|
||||
protected string m_version;
|
||||
|
||||
protected string m_pidFile = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Random uuid for private data
|
||||
@@ -96,35 +72,13 @@ namespace OpenSim.Framework.Servers
|
||||
get { return m_httpServer; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds the non-viewer statistics collection object for this service/server
|
||||
/// </summary>
|
||||
protected IStatsCollector m_stats;
|
||||
|
||||
public BaseOpenSimServer()
|
||||
public BaseOpenSimServer() : base()
|
||||
{
|
||||
m_startuptime = DateTime.Now;
|
||||
m_version = VersionInfo.Version;
|
||||
|
||||
// Random uuid for private data
|
||||
m_osSecret = UUID.Random().ToString();
|
||||
|
||||
m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics);
|
||||
m_periodicDiagnosticsTimer.Enabled = true;
|
||||
|
||||
// This thread will go on to become the console listening thread
|
||||
Thread.CurrentThread.Name = "ConsoleThread";
|
||||
|
||||
ILoggerRepository repository = LogManager.GetRepository();
|
||||
IAppender[] appenders = repository.GetAppenders();
|
||||
|
||||
foreach (IAppender appender in appenders)
|
||||
{
|
||||
if (appender.Name == "LogFileAppender")
|
||||
{
|
||||
m_logFileAppender = appender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -132,76 +86,18 @@ namespace OpenSim.Framework.Servers
|
||||
/// </summary>
|
||||
protected virtual void StartupSpecific()
|
||||
{
|
||||
if (m_console != null)
|
||||
{
|
||||
ILoggerRepository repository = LogManager.GetRepository();
|
||||
IAppender[] appenders = repository.GetAppenders();
|
||||
if (m_console == null)
|
||||
return;
|
||||
|
||||
foreach (IAppender appender in appenders)
|
||||
{
|
||||
if (appender.Name == "Console")
|
||||
{
|
||||
m_consoleAppender = (OpenSimAppender)appender;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RegisterCommonCommands();
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "quit",
|
||||
"quit",
|
||||
"Quit the application", HandleQuit);
|
||||
|
||||
if (null == m_consoleAppender)
|
||||
{
|
||||
Notice("No appender named Console found (see the log4net config file for this executable)!");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_consoleAppender.Console = m_console;
|
||||
|
||||
// If there is no threshold set then the threshold is effectively everything.
|
||||
if (null == m_consoleAppender.Threshold)
|
||||
m_consoleAppender.Threshold = Level.All;
|
||||
|
||||
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
|
||||
}
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "quit",
|
||||
"quit",
|
||||
"Quit the application", HandleQuit);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "shutdown",
|
||||
"shutdown",
|
||||
"Quit the application", HandleQuit);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "set log level",
|
||||
"set log level <level>",
|
||||
"Set the console logging level", HandleLogLevel);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "show info",
|
||||
"show info",
|
||||
"Show general information about the server", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "show stats",
|
||||
"show stats",
|
||||
"Show statistics", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "show threads",
|
||||
"show threads",
|
||||
"Show thread status", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "show uptime",
|
||||
"show uptime",
|
||||
"Show server uptime", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "show version",
|
||||
"show version",
|
||||
"Show server version", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "threads abort",
|
||||
"threads abort <thread-id>",
|
||||
"Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "threads show",
|
||||
"threads show",
|
||||
"Show thread status. Synonym for \"show threads\"",
|
||||
(string module, string[] args) => Notice(GetThreadsReport()));
|
||||
}
|
||||
m_console.Commands.AddCommand("General", false, "shutdown",
|
||||
"shutdown",
|
||||
"Quit the application", HandleQuit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,87 +122,19 @@ namespace OpenSim.Framework.Servers
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("DIAGNOSTICS\n\n");
|
||||
sb.Append(GetUptimeReport());
|
||||
|
||||
if (m_stats != null)
|
||||
{
|
||||
sb.Append(m_stats.Report());
|
||||
}
|
||||
|
||||
sb.Append(StatsManager.SimExtraStats.Report());
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.Append(GetThreadsReport());
|
||||
|
||||
m_log.Debug(sb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a report about the registered threads in this server.
|
||||
/// </summary>
|
||||
protected string GetThreadsReport()
|
||||
{
|
||||
// This should be a constant field.
|
||||
string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo();
|
||||
|
||||
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
|
||||
|
||||
int timeNow = Environment.TickCount & Int32.MaxValue;
|
||||
|
||||
sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE");
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
foreach (Watchdog.ThreadWatchdogInfo twi in threads)
|
||||
{
|
||||
Thread t = twi.Thread;
|
||||
|
||||
sb.AppendFormat(
|
||||
reportFormat,
|
||||
t.ManagedThreadId,
|
||||
t.Name,
|
||||
timeNow - twi.LastTick,
|
||||
timeNow - twi.FirstTick,
|
||||
t.Priority,
|
||||
t.ThreadState);
|
||||
|
||||
sb.Append("\n");
|
||||
}
|
||||
|
||||
sb.Append("\n");
|
||||
|
||||
// For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting
|
||||
// zero active threads.
|
||||
int totalThreads = Process.GetCurrentProcess().Threads.Count;
|
||||
if (totalThreads > 0)
|
||||
sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
|
||||
|
||||
sb.Append("Main threadpool (excluding script engine pools)\n");
|
||||
sb.Append(Util.GetThreadPoolReport());
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a report about the uptime of this server
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetUptimeReport()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now));
|
||||
sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime));
|
||||
sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs initialisation of the scene, such as loading configuration from disk.
|
||||
/// </summary>
|
||||
public virtual void Startup()
|
||||
{
|
||||
m_log.Info("[STARTUP]: Beginning startup processing");
|
||||
|
||||
EnhanceVersionInformation();
|
||||
|
||||
m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine);
|
||||
// clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
|
||||
@@ -341,271 +169,11 @@ namespace OpenSim.Framework.Servers
|
||||
private void HandleQuit(string module, string[] args)
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
private void HandleLogLevel(string module, string[] cmd)
|
||||
{
|
||||
if (null == m_consoleAppender)
|
||||
{
|
||||
Notice("No appender named Console found (see the log4net config file for this executable)!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd.Length > 3)
|
||||
{
|
||||
string rawLevel = cmd[3];
|
||||
|
||||
ILoggerRepository repository = LogManager.GetRepository();
|
||||
Level consoleLevel = repository.LevelMap[rawLevel];
|
||||
|
||||
if (consoleLevel != null)
|
||||
m_consoleAppender.Threshold = consoleLevel;
|
||||
else
|
||||
Notice(
|
||||
String.Format(
|
||||
"{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
|
||||
rawLevel));
|
||||
}
|
||||
|
||||
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show help information
|
||||
/// </summary>
|
||||
/// <param name="helpArgs"></param>
|
||||
protected virtual void ShowHelp(string[] helpArgs)
|
||||
{
|
||||
Notice("");
|
||||
|
||||
if (helpArgs.Length == 0)
|
||||
{
|
||||
Notice("set log level [level] - change the console logging level only. For example, off or debug.");
|
||||
Notice("show info - show server information (e.g. startup path).");
|
||||
|
||||
if (m_stats != null)
|
||||
Notice("show stats - show statistical information for this server");
|
||||
|
||||
Notice("show threads - list tracked threads");
|
||||
Notice("show uptime - show server startup time and uptime.");
|
||||
Notice("show version - show server version.");
|
||||
Notice("");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void HandleShow(string module, string[] cmd)
|
||||
{
|
||||
List<string> args = new List<string>(cmd);
|
||||
|
||||
args.RemoveAt(0);
|
||||
|
||||
string[] showParams = args.ToArray();
|
||||
|
||||
switch (showParams[0])
|
||||
{
|
||||
case "info":
|
||||
ShowInfo();
|
||||
break;
|
||||
|
||||
case "stats":
|
||||
if (m_stats != null)
|
||||
Notice(m_stats.Report());
|
||||
break;
|
||||
|
||||
case "threads":
|
||||
Notice(GetThreadsReport());
|
||||
break;
|
||||
|
||||
case "uptime":
|
||||
Notice(GetUptimeReport());
|
||||
break;
|
||||
|
||||
case "version":
|
||||
Notice(GetVersionText());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void HandleThreadsAbort(string module, string[] cmd)
|
||||
{
|
||||
if (cmd.Length != 3)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: threads abort <thread-id>");
|
||||
return;
|
||||
}
|
||||
|
||||
int threadId;
|
||||
if (!int.TryParse(cmd[2], out threadId))
|
||||
{
|
||||
MainConsole.Instance.Output("ERROR: Thread id must be an integer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Watchdog.AbortThread(threadId))
|
||||
MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
|
||||
else
|
||||
MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
|
||||
}
|
||||
|
||||
protected void ShowInfo()
|
||||
{
|
||||
Notice(GetVersionText());
|
||||
Notice("Startup directory: " + m_startupDirectory);
|
||||
if (null != m_consoleAppender)
|
||||
Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold));
|
||||
}
|
||||
|
||||
protected string GetVersionText()
|
||||
{
|
||||
return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Console output is only possible if a console has been established.
|
||||
/// That is something that cannot be determined within this class. So
|
||||
/// all attempts to use the console MUST be verified.
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
protected void Notice(string msg)
|
||||
{
|
||||
if (m_console != null)
|
||||
{
|
||||
m_console.Output(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Console output is only possible if a console has been established.
|
||||
/// That is something that cannot be determined within this class. So
|
||||
/// all attempts to use the console MUST be verified.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="components"></param>
|
||||
protected void Notice(string format, params string[] components)
|
||||
{
|
||||
if (m_console != null)
|
||||
m_console.OutputFormat(format, components);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enhance the version string with extra information if it's available.
|
||||
/// </summary>
|
||||
protected void EnhanceVersionInformation()
|
||||
{
|
||||
string buildVersion = string.Empty;
|
||||
|
||||
// The subversion information is deprecated and will be removed at a later date
|
||||
// Add subversion revision information if available
|
||||
// Try file "svn_revision" in the current directory first, then the .svn info.
|
||||
// This allows to make the revision available in simulators not running from the source tree.
|
||||
// FIXME: Making an assumption about the directory we're currently in - we do this all over the place
|
||||
// elsewhere as well
|
||||
string gitDir = "../.git/";
|
||||
string gitRefPointerPath = gitDir + "HEAD";
|
||||
|
||||
string svnRevisionFileName = "svn_revision";
|
||||
string svnFileName = ".svn/entries";
|
||||
string manualVersionFileName = ".version";
|
||||
string inputLine;
|
||||
int strcmp;
|
||||
|
||||
if (File.Exists(manualVersionFileName))
|
||||
{
|
||||
using (StreamReader CommitFile = File.OpenText(manualVersionFileName))
|
||||
buildVersion = CommitFile.ReadLine();
|
||||
|
||||
m_version += buildVersion ?? "";
|
||||
}
|
||||
else if (File.Exists(gitRefPointerPath))
|
||||
{
|
||||
// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath);
|
||||
|
||||
string rawPointer = "";
|
||||
|
||||
using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
|
||||
rawPointer = pointerFile.ReadLine();
|
||||
|
||||
// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer);
|
||||
|
||||
Match m = Regex.Match(rawPointer, "^ref: (.+)$");
|
||||
|
||||
if (m.Success)
|
||||
{
|
||||
// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value);
|
||||
|
||||
string gitRef = m.Groups[1].Value;
|
||||
string gitRefPath = gitDir + gitRef;
|
||||
if (File.Exists(gitRefPath))
|
||||
{
|
||||
// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath);
|
||||
|
||||
using (StreamReader refFile = File.OpenText(gitRefPath))
|
||||
{
|
||||
string gitHash = refFile.ReadLine();
|
||||
m_version += gitHash.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove the else logic when subversion mirror is no longer used
|
||||
if (File.Exists(svnRevisionFileName))
|
||||
{
|
||||
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
|
||||
buildVersion = RevisionFile.ReadLine();
|
||||
buildVersion.Trim();
|
||||
RevisionFile.Close();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
|
||||
{
|
||||
StreamReader EntriesFile = File.OpenText(svnFileName);
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
while (inputLine != null)
|
||||
{
|
||||
// using the dir svn revision at the top of entries file
|
||||
strcmp = String.Compare(inputLine, "dir");
|
||||
if (strcmp == 0)
|
||||
{
|
||||
buildVersion = EntriesFile.ReadLine();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
}
|
||||
}
|
||||
EntriesFile.Close();
|
||||
}
|
||||
|
||||
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CreatePIDFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
|
||||
FileStream fs = File.Create(path);
|
||||
|
||||
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
|
||||
fs.Write(buf, 0, buf.Length);
|
||||
fs.Close();
|
||||
m_pidFile = path;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string osSecret {
|
||||
// Secret uuid for the simulator
|
||||
get { return m_osSecret; }
|
||||
|
||||
get { return m_osSecret; }
|
||||
}
|
||||
|
||||
public string StatReport(IOSHttpRequest httpRequest)
|
||||
@@ -613,27 +181,12 @@ namespace OpenSim.Framework.Servers
|
||||
// If we catch a request for "callback", wrap the response in the value for jsonp
|
||||
if (httpRequest.Query.ContainsKey("callback"))
|
||||
{
|
||||
return httpRequest.Query["callback"].ToString() + "(" + m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");";
|
||||
return httpRequest.Query["callback"].ToString() + "(" + StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");";
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemovePIDFile()
|
||||
{
|
||||
if (m_pidFile != String.Empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(m_pidFile);
|
||||
m_pidFile = String.Empty;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,23 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the debug level.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// See MainServer.DebugLevel.
|
||||
/// </value>
|
||||
public int DebugLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Request number for diagnostic purposes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is an internal number. In some debug situations an external number may also be supplied in the
|
||||
/// opensim-request-id header but we are not currently logging this.
|
||||
/// </remarks>
|
||||
public int RequestNumber { get; private set; }
|
||||
|
||||
private volatile int NotSocketErrors = 0;
|
||||
public volatile bool HTTPDRunning = false;
|
||||
|
||||
@@ -67,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
|
||||
protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
|
||||
protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
|
||||
protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
|
||||
// protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
|
||||
protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
|
||||
new Dictionary<string, PollServiceEventArgs>();
|
||||
|
||||
@@ -245,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
return new List<string>(m_pollHandlers.Keys);
|
||||
}
|
||||
|
||||
// Note that the agent string is provided simply to differentiate
|
||||
// the handlers - it is NOT required to be an actual agent header
|
||||
// value.
|
||||
public bool AddAgentHandler(string agent, IHttpAgentHandler handler)
|
||||
{
|
||||
lock (m_agentHandlers)
|
||||
{
|
||||
if (!m_agentHandlers.ContainsKey(agent))
|
||||
{
|
||||
m_agentHandlers.Add(agent, handler);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//must already have a handler for that path so return false
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<string> GetAgentHandlerKeys()
|
||||
{
|
||||
lock (m_agentHandlers)
|
||||
return new List<string>(m_agentHandlers.Keys);
|
||||
}
|
||||
// // Note that the agent string is provided simply to differentiate
|
||||
// // the handlers - it is NOT required to be an actual agent header
|
||||
// // value.
|
||||
// public bool AddAgentHandler(string agent, IHttpAgentHandler handler)
|
||||
// {
|
||||
// lock (m_agentHandlers)
|
||||
// {
|
||||
// if (!m_agentHandlers.ContainsKey(agent))
|
||||
// {
|
||||
// m_agentHandlers.Add(agent, handler);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //must already have a handler for that path so return false
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public List<string> GetAgentHandlerKeys()
|
||||
// {
|
||||
// lock (m_agentHandlers)
|
||||
// return new List<string>(m_agentHandlers.Keys);
|
||||
// }
|
||||
|
||||
public bool AddLLSDHandler(string path, LLSDMethod handler)
|
||||
{
|
||||
@@ -296,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
|
||||
private void OnRequest(object source, RequestEventArgs args)
|
||||
{
|
||||
RequestNumber++;
|
||||
|
||||
try
|
||||
{
|
||||
IHttpClientContext context = (IHttpClientContext)source;
|
||||
@@ -405,7 +422,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
string requestMethod = request.HttpMethod;
|
||||
string uriString = request.RawUrl;
|
||||
|
||||
// string reqnum = "unknown";
|
||||
int requestStartTick = Environment.TickCount;
|
||||
|
||||
// Will be adjusted later on.
|
||||
@@ -420,24 +436,24 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
// reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]);
|
||||
//m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl);
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true);
|
||||
Culture.SetCurrentCulture();
|
||||
|
||||
// This is the REST agent interface. We require an agent to properly identify
|
||||
// itself. If the REST handler recognizes the prefix it will attempt to
|
||||
// satisfy the request. If it is not recognizable, and no damage has occurred
|
||||
// the request can be passed through to the other handlers. This is a low
|
||||
// probability event; if a request is matched it is normally expected to be
|
||||
// handled
|
||||
IHttpAgentHandler agentHandler;
|
||||
|
||||
if (TryGetAgentHandler(request, response, out agentHandler))
|
||||
{
|
||||
if (HandleAgentRequest(agentHandler, request, response))
|
||||
{
|
||||
requestEndTick = Environment.TickCount;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// // This is the REST agent interface. We require an agent to properly identify
|
||||
// // itself. If the REST handler recognizes the prefix it will attempt to
|
||||
// // satisfy the request. If it is not recognizable, and no damage has occurred
|
||||
// // the request can be passed through to the other handlers. This is a low
|
||||
// // probability event; if a request is matched it is normally expected to be
|
||||
// // handled
|
||||
// IHttpAgentHandler agentHandler;
|
||||
//
|
||||
// if (TryGetAgentHandler(request, response, out agentHandler))
|
||||
// {
|
||||
// if (HandleAgentRequest(agentHandler, request, response))
|
||||
// {
|
||||
// requestEndTick = Environment.TickCount;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
//response.KeepAlive = true;
|
||||
response.SendChunked = false;
|
||||
@@ -449,9 +465,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
if (TryGetStreamHandler(handlerKey, out requestHandler))
|
||||
{
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}",
|
||||
request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
|
||||
LogIncomingToStreamHandler(request, requestHandler);
|
||||
|
||||
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
|
||||
|
||||
@@ -528,11 +542,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
case null:
|
||||
case "text/html":
|
||||
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
|
||||
request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
|
||||
LogIncomingToContentTypeHandler(request);
|
||||
|
||||
buffer = HandleHTTPRequest(request, response);
|
||||
break;
|
||||
@@ -540,11 +551,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
case "application/llsd+xml":
|
||||
case "application/xml+llsd":
|
||||
case "application/llsd+json":
|
||||
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
|
||||
request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
|
||||
LogIncomingToContentTypeHandler(request);
|
||||
|
||||
buffer = HandleLLSDRequests(request, response);
|
||||
break;
|
||||
@@ -563,9 +571,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
if (DoWeHaveALLSDHandler(request.RawUrl))
|
||||
{
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
|
||||
request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
|
||||
LogIncomingToContentTypeHandler(request);
|
||||
|
||||
buffer = HandleLLSDRequests(request, response);
|
||||
}
|
||||
@@ -573,18 +579,14 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
else if (DoWeHaveAHTTPHandler(request.RawUrl))
|
||||
{
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
|
||||
request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
|
||||
LogIncomingToContentTypeHandler(request);
|
||||
|
||||
buffer = HandleHTTPRequest(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
|
||||
request.HttpMethod, request.Url.PathAndQuery);
|
||||
LogIncomingToXmlRpcHandler(request);
|
||||
|
||||
// generic login request.
|
||||
buffer = HandleXmlRpcRequests(request, response);
|
||||
@@ -643,14 +645,93 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
if (tickdiff > 3000)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms",
|
||||
"[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
|
||||
RequestNumber,
|
||||
requestMethod,
|
||||
uriString,
|
||||
requestHandler != null ? requestHandler.Name : "",
|
||||
requestHandler != null ? requestHandler.Description : "",
|
||||
request.RemoteIPEndPoint.ToString(),
|
||||
request.RemoteIPEndPoint,
|
||||
tickdiff);
|
||||
}
|
||||
else if (DebugLevel >= 4)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms",
|
||||
RequestNumber,
|
||||
Port,
|
||||
tickdiff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}",
|
||||
RequestNumber,
|
||||
Port,
|
||||
request.HttpMethod,
|
||||
request.Url.PathAndQuery,
|
||||
requestHandler.Name,
|
||||
requestHandler.Description,
|
||||
request.RemoteIPEndPoint);
|
||||
|
||||
if (DebugLevel >= 5)
|
||||
LogIncomingInDetail(request);
|
||||
}
|
||||
|
||||
private void LogIncomingToContentTypeHandler(OSHttpRequest request)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
|
||||
RequestNumber,
|
||||
Port,
|
||||
(request.ContentType == null || request.ContentType == "") ? "not set" : request.ContentType,
|
||||
request.HttpMethod,
|
||||
request.Url.PathAndQuery,
|
||||
request.RemoteIPEndPoint);
|
||||
|
||||
if (DebugLevel >= 5)
|
||||
LogIncomingInDetail(request);
|
||||
}
|
||||
|
||||
private void LogIncomingToXmlRpcHandler(OSHttpRequest request)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}",
|
||||
RequestNumber,
|
||||
Port,
|
||||
request.HttpMethod,
|
||||
request.Url.PathAndQuery,
|
||||
request.RemoteIPEndPoint);
|
||||
|
||||
if (DebugLevel >= 5)
|
||||
LogIncomingInDetail(request);
|
||||
}
|
||||
|
||||
private void LogIncomingInDetail(OSHttpRequest request)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8))
|
||||
{
|
||||
string output;
|
||||
|
||||
if (DebugLevel == 5)
|
||||
{
|
||||
const int sampleLength = 80;
|
||||
char[] sampleChars = new char[sampleLength + 3];
|
||||
reader.Read(sampleChars, 0, sampleLength);
|
||||
sampleChars[80] = '.';
|
||||
sampleChars[81] = '.';
|
||||
sampleChars[82] = '.';
|
||||
output = new string(sampleChars);
|
||||
}
|
||||
else
|
||||
{
|
||||
output = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[BASE HTTP SERVER]: {0}", output.Replace("\n", @"\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,24 +827,24 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
|
||||
{
|
||||
agentHandler = null;
|
||||
|
||||
lock (m_agentHandlers)
|
||||
{
|
||||
foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
|
||||
{
|
||||
if (handler.Match(request, response))
|
||||
{
|
||||
agentHandler = handler;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
|
||||
// {
|
||||
// agentHandler = null;
|
||||
//
|
||||
// lock (m_agentHandlers)
|
||||
// {
|
||||
// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
|
||||
// {
|
||||
// if (handler.Match(request, response))
|
||||
// {
|
||||
// agentHandler = handler;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Try all the registered xmlrpc handlers when an xmlrpc request is received.
|
||||
@@ -1201,59 +1282,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
map["login"] = OSD.FromString("false");
|
||||
return map;
|
||||
}
|
||||
/// <summary>
|
||||
/// A specific agent handler was provided. Such a handler is expecetd to have an
|
||||
/// intimate, and highly specific relationship with the client. Consequently,
|
||||
/// nothing is done here.
|
||||
/// </summary>
|
||||
/// <param name="handler"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="response"></param>
|
||||
|
||||
private bool HandleAgentRequest(IHttpAgentHandler handler, OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
// In the case of REST, then handler is responsible for ALL aspects of
|
||||
// the request/response handling. Nothing is done here, not even encoding.
|
||||
|
||||
try
|
||||
{
|
||||
return handler.Handle(request, response);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// If the handler did in fact close the stream, then this will blow
|
||||
// chunks. So that that doesn't disturb anybody we throw away any
|
||||
// and all exceptions raised. We've done our best to release the
|
||||
// client.
|
||||
try
|
||||
{
|
||||
m_log.Warn("[HTTP-AGENT]: Error - " + e.Message);
|
||||
response.SendChunked = false;
|
||||
response.KeepAlive = true;
|
||||
response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError;
|
||||
//response.OutputStream.Close();
|
||||
try
|
||||
{
|
||||
response.Send();
|
||||
//response.FreeContext();
|
||||
}
|
||||
catch (SocketException f)
|
||||
{
|
||||
// This has to be here to prevent a Linux/Mono crash
|
||||
m_log.Warn(
|
||||
String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", f.Message), f);
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Indicate that the request has been "handled"
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
@@ -1688,21 +1716,21 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
m_pollHandlers.Remove(path);
|
||||
}
|
||||
|
||||
public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
|
||||
{
|
||||
lock (m_agentHandlers)
|
||||
{
|
||||
IHttpAgentHandler foundHandler;
|
||||
|
||||
if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler)
|
||||
{
|
||||
m_agentHandlers.Remove(agent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
|
||||
// {
|
||||
// lock (m_agentHandlers)
|
||||
// {
|
||||
// IHttpAgentHandler foundHandler;
|
||||
//
|
||||
// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler)
|
||||
// {
|
||||
// m_agentHandlers.Remove(agent);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public void RemoveXmlRPCHandler(string method)
|
||||
{
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
uint Port { get; }
|
||||
bool UseSSL { get; }
|
||||
|
||||
// Note that the agent string is provided simply to differentiate
|
||||
// the handlers - it is NOT required to be an actual agent header
|
||||
// value.
|
||||
bool AddAgentHandler(string agent, IHttpAgentHandler handler);
|
||||
// // Note that the agent string is provided simply to differentiate
|
||||
// // the handlers - it is NOT required to be an actual agent header
|
||||
// // value.
|
||||
// bool AddAgentHandler(string agent, IHttpAgentHandler handler);
|
||||
|
||||
/// <summary>
|
||||
/// Add a handler for an HTTP request.
|
||||
@@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
|
||||
bool SetDefaultLLSDHandler(DefaultLLSDMethod handler);
|
||||
|
||||
/// <summary>
|
||||
/// Remove the agent if it is registered.
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
/// <param name="handler"></param>
|
||||
/// <returns></returns>
|
||||
bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
|
||||
// /// <summary>
|
||||
// /// Remove the agent if it is registered.
|
||||
// /// </summary>
|
||||
// /// <param name="agent"></param>
|
||||
// /// <param name="handler"></param>
|
||||
// /// <returns></returns>
|
||||
// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
|
||||
|
||||
/// <summary>
|
||||
/// Remove an HTTP handler
|
||||
|
||||
@@ -29,6 +29,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
@@ -47,9 +48,12 @@ namespace OpenSim.Framework.Servers
|
||||
/// Control the printing of certain debug messages.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If DebugLevel >= 1, then short warnings are logged when receiving bad input data.
|
||||
/// If DebugLevel >= 2, then long warnings are logged when receiving bad input data.
|
||||
/// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged.
|
||||
/// If DebugLevel >= 1 then short warnings are logged when receiving bad input data.
|
||||
/// If DebugLevel >= 2 then long warnings are logged when receiving bad input data.
|
||||
/// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged.
|
||||
/// If DebugLevel >= 4 then the time taken to fulfill the request is logged.
|
||||
/// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged.
|
||||
/// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged.
|
||||
/// </remarks>
|
||||
public static int DebugLevel
|
||||
{
|
||||
@@ -101,17 +105,28 @@ namespace OpenSim.Framework.Servers
|
||||
get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
|
||||
}
|
||||
|
||||
|
||||
public static void RegisterHttpConsoleCommands(ICommandConsole console)
|
||||
{
|
||||
console.Commands.AddCommand(
|
||||
"Debug", false, "debug http", "debug http [<level>]",
|
||||
"Turn on inbound non-poll http request debugging.",
|
||||
"If level <= 0, then no extra logging is done.\n"
|
||||
+ "If level >= 1, then short warnings are logged when receiving bad input data.\n"
|
||||
+ "If level >= 2, then long warnings are logged when receiving bad input data.\n"
|
||||
+ "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
|
||||
+ "If no level is specified then the current level is returned.",
|
||||
"Comms", false, "show http-handlers",
|
||||
"show http-handlers",
|
||||
"Show all registered http handlers", HandleShowHttpHandlersCommand);
|
||||
|
||||
console.Commands.AddCommand(
|
||||
"Debug", false, "debug http", "debug http <in|out|all> [<level>]",
|
||||
"Turn on http request logging.",
|
||||
"If in or all and\n"
|
||||
+ " level <= 0 then no extra logging is done.\n"
|
||||
+ " level >= 1 then short warnings are logged when receiving bad input data.\n"
|
||||
+ " level >= 2 then long warnings are logged when receiving bad input data.\n"
|
||||
+ " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n"
|
||||
+ " level >= 4 then the time taken to fulfill the request is logged.\n"
|
||||
+ " level >= 5 then a sample from the beginning of the incoming data is logged.\n"
|
||||
+ " level >= 6 then the entire incoming data is logged.\n"
|
||||
+ " no level is specified then the current level is returned.\n\n"
|
||||
+ "If out or all and\n"
|
||||
+ " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n"
|
||||
+ " level >= 4 then the time taken to fulfill the request is logged.\n",
|
||||
HandleDebugHttpCommand);
|
||||
}
|
||||
|
||||
@@ -119,25 +134,120 @@ namespace OpenSim.Framework.Servers
|
||||
/// Turn on some debugging values for OpenSim.
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
private static void HandleDebugHttpCommand(string module, string[] args)
|
||||
private static void HandleDebugHttpCommand(string module, string[] cmdparams)
|
||||
{
|
||||
if (args.Length == 3)
|
||||
if (cmdparams.Length < 3)
|
||||
{
|
||||
int newDebug;
|
||||
if (int.TryParse(args[2], out newDebug))
|
||||
{
|
||||
MainServer.DebugLevel = newDebug;
|
||||
MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
|
||||
}
|
||||
MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..6");
|
||||
return;
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
|
||||
bool inReqs = false;
|
||||
bool outReqs = false;
|
||||
bool allReqs = false;
|
||||
|
||||
string subCommand = cmdparams[2];
|
||||
|
||||
if (subCommand.ToLower() == "in")
|
||||
{
|
||||
MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
|
||||
inReqs = true;
|
||||
}
|
||||
else if (subCommand.ToLower() == "out")
|
||||
{
|
||||
outReqs = true;
|
||||
}
|
||||
else if (subCommand.ToLower() == "all")
|
||||
{
|
||||
allReqs = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug http 0..3");
|
||||
MainConsole.Instance.Output("You must specify in, out or all");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmdparams.Length >= 4)
|
||||
{
|
||||
string rawNewDebug = cmdparams[3];
|
||||
int newDebug;
|
||||
|
||||
if (!int.TryParse(rawNewDebug, out newDebug))
|
||||
{
|
||||
MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newDebug < 0 || newDebug > 6)
|
||||
{
|
||||
MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug);
|
||||
return;
|
||||
}
|
||||
|
||||
if (allReqs || inReqs)
|
||||
{
|
||||
MainServer.DebugLevel = newDebug;
|
||||
MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug);
|
||||
}
|
||||
|
||||
if (allReqs || outReqs)
|
||||
{
|
||||
WebUtil.DebugLevel = newDebug;
|
||||
MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allReqs || inReqs)
|
||||
MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel);
|
||||
|
||||
if (allReqs || outReqs)
|
||||
MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleShowHttpHandlersCommand(string module, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: show http-handlers");
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder handlers = new StringBuilder();
|
||||
|
||||
lock (m_Servers)
|
||||
{
|
||||
foreach (BaseHttpServer httpServer in m_Servers.Values)
|
||||
{
|
||||
handlers.AppendFormat(
|
||||
"Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port);
|
||||
|
||||
handlers.AppendFormat("* XMLRPC:\n");
|
||||
foreach (String s in httpServer.GetXmlRpcHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* HTTP:\n");
|
||||
List<String> poll = httpServer.GetPollServiceHandlerKeys();
|
||||
foreach (String s in httpServer.GetHTTPHandlerKeys())
|
||||
handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
|
||||
|
||||
// handlers.AppendFormat("* Agent:\n");
|
||||
// foreach (String s in httpServer.GetAgentHandlerKeys())
|
||||
// handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* LLSD:\n");
|
||||
foreach (String s in httpServer.GetLLSDHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count);
|
||||
foreach (String s in httpServer.GetStreamHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.Append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(handlers.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
677
OpenSim/Framework/Servers/ServerBase.cs
Normal file
677
OpenSim/Framework/Servers/ServerBase.cs
Normal file
@@ -0,0 +1,677 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Core;
|
||||
using log4net.Repository;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
public class ServerBase
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public IConfigSource Config { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Console to be used for any command line output. Can be null, in which case there should be no output.
|
||||
/// </summary>
|
||||
protected ICommandConsole m_console;
|
||||
|
||||
protected OpenSimAppender m_consoleAppender;
|
||||
protected FileAppender m_logFileAppender;
|
||||
|
||||
protected DateTime m_startuptime;
|
||||
protected string m_startupDirectory = Environment.CurrentDirectory;
|
||||
|
||||
protected string m_pidFile = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
|
||||
/// </summary>
|
||||
protected string m_version;
|
||||
|
||||
public ServerBase()
|
||||
{
|
||||
m_startuptime = DateTime.Now;
|
||||
m_version = VersionInfo.Version;
|
||||
EnhanceVersionInformation();
|
||||
}
|
||||
|
||||
protected void CreatePIDFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
|
||||
|
||||
using (FileStream fs = File.Create(path))
|
||||
{
|
||||
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
|
||||
fs.Write(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
m_pidFile = path;
|
||||
|
||||
m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemovePIDFile()
|
||||
{
|
||||
if (m_pidFile != String.Empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(m_pidFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e);
|
||||
}
|
||||
|
||||
m_pidFile = String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCommonAppenders(IConfig startupConfig)
|
||||
{
|
||||
ILoggerRepository repository = LogManager.GetRepository();
|
||||
IAppender[] appenders = repository.GetAppenders();
|
||||
|
||||
foreach (IAppender appender in appenders)
|
||||
{
|
||||
if (appender.Name == "Console")
|
||||
{
|
||||
m_consoleAppender = (OpenSimAppender)appender;
|
||||
}
|
||||
else if (appender.Name == "LogFileAppender")
|
||||
{
|
||||
m_logFileAppender = (FileAppender)appender;
|
||||
}
|
||||
}
|
||||
|
||||
if (null == m_consoleAppender)
|
||||
{
|
||||
Notice("No appender named Console found (see the log4net config file for this executable)!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: This should be done through an interface rather than casting.
|
||||
m_consoleAppender.Console = (ConsoleBase)m_console;
|
||||
|
||||
// If there is no threshold set then the threshold is effectively everything.
|
||||
if (null == m_consoleAppender.Threshold)
|
||||
m_consoleAppender.Threshold = Level.All;
|
||||
|
||||
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
|
||||
}
|
||||
|
||||
if (m_logFileAppender != null && startupConfig != null)
|
||||
{
|
||||
string cfgFileName = startupConfig.GetString("LogFile", null);
|
||||
if (cfgFileName != null)
|
||||
{
|
||||
m_logFileAppender.File = cfgFileName;
|
||||
m_logFileAppender.ActivateOptions();
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register common commands once m_console has been set if it is going to be set
|
||||
/// </summary>
|
||||
public void RegisterCommonCommands()
|
||||
{
|
||||
if (m_console == null)
|
||||
return;
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "show info", "show info", "Show general information about the server", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "show version", "show version", "Show server version", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "get log level", "get log level", "Get the current console logging level",
|
||||
(mod, cmd) => ShowLogLevel());
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "set log level", "set log level <level>",
|
||||
"Set the console logging level for this session.", HandleSetLogLevel);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "config set",
|
||||
"config set <section> <key> <value>",
|
||||
"Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "config get",
|
||||
"config get [<section>] [<key>]",
|
||||
"Synonym for config show",
|
||||
HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "config show",
|
||||
"config show [<section>] [<key>]",
|
||||
"Show config information",
|
||||
"If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
|
||||
+ "If a section is given but not a field, then all fields in that section are printed.",
|
||||
HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "config save",
|
||||
"config save <path>",
|
||||
"Save current configuration to a file at the given path", HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "command-script",
|
||||
"command-script <script>",
|
||||
"Run a command script from file", HandleScript);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "show threads",
|
||||
"show threads",
|
||||
"Show thread status", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "threads abort",
|
||||
"threads abort <thread-id>",
|
||||
"Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "threads show",
|
||||
"threads show",
|
||||
"Show thread status. Synonym for \"show threads\"",
|
||||
(string module, string[] args) => Notice(GetThreadsReport()));
|
||||
|
||||
m_console.Commands.AddCommand(
|
||||
"General", false, "force gc",
|
||||
"force gc",
|
||||
"Manually invoke runtime garbage collection. For debugging purposes",
|
||||
HandleForceGc);
|
||||
}
|
||||
|
||||
private void HandleForceGc(string module, string[] args)
|
||||
{
|
||||
Notice("Manually invoking runtime garbage collection");
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public virtual void HandleShow(string module, string[] cmd)
|
||||
{
|
||||
List<string> args = new List<string>(cmd);
|
||||
|
||||
args.RemoveAt(0);
|
||||
|
||||
string[] showParams = args.ToArray();
|
||||
|
||||
switch (showParams[0])
|
||||
{
|
||||
case "info":
|
||||
ShowInfo();
|
||||
break;
|
||||
|
||||
case "version":
|
||||
Notice(GetVersionText());
|
||||
break;
|
||||
|
||||
case "uptime":
|
||||
Notice(GetUptimeReport());
|
||||
break;
|
||||
|
||||
case "threads":
|
||||
Notice(GetThreadsReport());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change and load configuration file data.
|
||||
/// </summary>
|
||||
/// <param name="module"></param>
|
||||
/// <param name="cmd"></param>
|
||||
private void HandleConfig(string module, string[] cmd)
|
||||
{
|
||||
List<string> args = new List<string>(cmd);
|
||||
args.RemoveAt(0);
|
||||
string[] cmdparams = args.ToArray();
|
||||
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
string firstParam = cmdparams[0].ToLower();
|
||||
|
||||
switch (firstParam)
|
||||
{
|
||||
case "set":
|
||||
if (cmdparams.Length < 4)
|
||||
{
|
||||
Notice("Syntax: config set <section> <key> <value>");
|
||||
Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
|
||||
}
|
||||
else
|
||||
{
|
||||
IConfig c;
|
||||
IConfigSource source = new IniConfigSource();
|
||||
c = source.AddConfig(cmdparams[1]);
|
||||
if (c != null)
|
||||
{
|
||||
string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
|
||||
c.Set(cmdparams[2], _value);
|
||||
Config.Merge(source);
|
||||
|
||||
Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "get":
|
||||
case "show":
|
||||
if (cmdparams.Length == 1)
|
||||
{
|
||||
foreach (IConfig config in Config.Configs)
|
||||
{
|
||||
Notice("[{0}]", config.Name);
|
||||
string[] keys = config.GetKeys();
|
||||
foreach (string key in keys)
|
||||
Notice(" {0} = {1}", key, config.GetString(key));
|
||||
}
|
||||
}
|
||||
else if (cmdparams.Length == 2 || cmdparams.Length == 3)
|
||||
{
|
||||
IConfig config = Config.Configs[cmdparams[1]];
|
||||
if (config == null)
|
||||
{
|
||||
Notice("Section \"{0}\" does not exist.",cmdparams[1]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cmdparams.Length == 2)
|
||||
{
|
||||
Notice("[{0}]", config.Name);
|
||||
foreach (string key in config.GetKeys())
|
||||
Notice(" {0} = {1}", key, config.GetString(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
Notice(
|
||||
"config get {0} {1} : {2}",
|
||||
cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
|
||||
Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "save":
|
||||
if (cmdparams.Length < 2)
|
||||
{
|
||||
Notice("Syntax: config save <path>");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = cmdparams[1];
|
||||
Notice("Saving configuration file: {0}", path);
|
||||
|
||||
if (Config is IniConfigSource)
|
||||
{
|
||||
IniConfigSource iniCon = (IniConfigSource)Config;
|
||||
iniCon.Save(path);
|
||||
}
|
||||
else if (Config is XmlConfigSource)
|
||||
{
|
||||
XmlConfigSource xmlCon = (XmlConfigSource)Config;
|
||||
xmlCon.Save(path);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSetLogLevel(string module, string[] cmd)
|
||||
{
|
||||
if (cmd.Length != 4)
|
||||
{
|
||||
Notice("Usage: set log level <level>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == m_consoleAppender)
|
||||
{
|
||||
Notice("No appender named Console found (see the log4net config file for this executable)!");
|
||||
return;
|
||||
}
|
||||
|
||||
string rawLevel = cmd[3];
|
||||
|
||||
ILoggerRepository repository = LogManager.GetRepository();
|
||||
Level consoleLevel = repository.LevelMap[rawLevel];
|
||||
|
||||
if (consoleLevel != null)
|
||||
m_consoleAppender.Threshold = consoleLevel;
|
||||
else
|
||||
Notice(
|
||||
"{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
|
||||
rawLevel);
|
||||
|
||||
ShowLogLevel();
|
||||
}
|
||||
|
||||
private void ShowLogLevel()
|
||||
{
|
||||
Notice("Console log level is {0}", m_consoleAppender.Threshold);
|
||||
}
|
||||
|
||||
protected virtual void HandleScript(string module, string[] parms)
|
||||
{
|
||||
if (parms.Length != 2)
|
||||
{
|
||||
Notice("Usage: command-script <path-to-script");
|
||||
return;
|
||||
}
|
||||
|
||||
RunCommandScript(parms[1]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an optional startup list of commands
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
protected void RunCommandScript(string fileName)
|
||||
{
|
||||
if (m_console == null)
|
||||
return;
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
m_log.Info("[SERVER BASE]: Running " + fileName);
|
||||
|
||||
using (StreamReader readFile = File.OpenText(fileName))
|
||||
{
|
||||
string currentCommand;
|
||||
while ((currentCommand = readFile.ReadLine()) != null)
|
||||
{
|
||||
currentCommand = currentCommand.Trim();
|
||||
if (!(currentCommand == ""
|
||||
|| currentCommand.StartsWith(";")
|
||||
|| currentCommand.StartsWith("//")
|
||||
|| currentCommand.StartsWith("#")))
|
||||
{
|
||||
m_log.Info("[SERVER BASE]: Running '" + currentCommand + "'");
|
||||
m_console.RunCommand(currentCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a report about the uptime of this server
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetUptimeReport()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now));
|
||||
sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime));
|
||||
sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected void ShowInfo()
|
||||
{
|
||||
Notice(GetVersionText());
|
||||
Notice("Startup directory: " + m_startupDirectory);
|
||||
if (null != m_consoleAppender)
|
||||
Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enhance the version string with extra information if it's available.
|
||||
/// </summary>
|
||||
protected void EnhanceVersionInformation()
|
||||
{
|
||||
string buildVersion = string.Empty;
|
||||
|
||||
// The subversion information is deprecated and will be removed at a later date
|
||||
// Add subversion revision information if available
|
||||
// Try file "svn_revision" in the current directory first, then the .svn info.
|
||||
// This allows to make the revision available in simulators not running from the source tree.
|
||||
// FIXME: Making an assumption about the directory we're currently in - we do this all over the place
|
||||
// elsewhere as well
|
||||
string gitDir = "../.git/";
|
||||
string gitRefPointerPath = gitDir + "HEAD";
|
||||
|
||||
string svnRevisionFileName = "svn_revision";
|
||||
string svnFileName = ".svn/entries";
|
||||
string manualVersionFileName = ".version";
|
||||
string inputLine;
|
||||
int strcmp;
|
||||
|
||||
if (File.Exists(manualVersionFileName))
|
||||
{
|
||||
using (StreamReader CommitFile = File.OpenText(manualVersionFileName))
|
||||
buildVersion = CommitFile.ReadLine();
|
||||
|
||||
m_version += buildVersion ?? "";
|
||||
}
|
||||
else if (File.Exists(gitRefPointerPath))
|
||||
{
|
||||
// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath);
|
||||
|
||||
string rawPointer = "";
|
||||
|
||||
using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
|
||||
rawPointer = pointerFile.ReadLine();
|
||||
|
||||
// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer);
|
||||
|
||||
Match m = Regex.Match(rawPointer, "^ref: (.+)$");
|
||||
|
||||
if (m.Success)
|
||||
{
|
||||
// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value);
|
||||
|
||||
string gitRef = m.Groups[1].Value;
|
||||
string gitRefPath = gitDir + gitRef;
|
||||
if (File.Exists(gitRefPath))
|
||||
{
|
||||
// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath);
|
||||
|
||||
using (StreamReader refFile = File.OpenText(gitRefPath))
|
||||
{
|
||||
string gitHash = refFile.ReadLine();
|
||||
m_version += gitHash.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove the else logic when subversion mirror is no longer used
|
||||
if (File.Exists(svnRevisionFileName))
|
||||
{
|
||||
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
|
||||
buildVersion = RevisionFile.ReadLine();
|
||||
buildVersion.Trim();
|
||||
RevisionFile.Close();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
|
||||
{
|
||||
StreamReader EntriesFile = File.OpenText(svnFileName);
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
while (inputLine != null)
|
||||
{
|
||||
// using the dir svn revision at the top of entries file
|
||||
strcmp = String.Compare(inputLine, "dir");
|
||||
if (strcmp == 0)
|
||||
{
|
||||
buildVersion = EntriesFile.ReadLine();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
}
|
||||
}
|
||||
EntriesFile.Close();
|
||||
}
|
||||
|
||||
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
|
||||
}
|
||||
}
|
||||
|
||||
protected string GetVersionText()
|
||||
{
|
||||
return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a report about the registered threads in this server.
|
||||
/// </summary>
|
||||
protected string GetThreadsReport()
|
||||
{
|
||||
// This should be a constant field.
|
||||
string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo();
|
||||
|
||||
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
|
||||
|
||||
int timeNow = Environment.TickCount & Int32.MaxValue;
|
||||
|
||||
sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE");
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
foreach (Watchdog.ThreadWatchdogInfo twi in threads)
|
||||
{
|
||||
Thread t = twi.Thread;
|
||||
|
||||
sb.AppendFormat(
|
||||
reportFormat,
|
||||
t.ManagedThreadId,
|
||||
t.Name,
|
||||
timeNow - twi.LastTick,
|
||||
timeNow - twi.FirstTick,
|
||||
t.Priority,
|
||||
t.ThreadState);
|
||||
|
||||
sb.Append("\n");
|
||||
}
|
||||
|
||||
sb.Append("\n");
|
||||
|
||||
// For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting
|
||||
// zero active threads.
|
||||
int totalThreads = Process.GetCurrentProcess().Threads.Count;
|
||||
if (totalThreads > 0)
|
||||
sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
|
||||
|
||||
sb.Append("Main threadpool (excluding script engine pools)\n");
|
||||
sb.Append(Util.GetThreadPoolReport());
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public virtual void HandleThreadsAbort(string module, string[] cmd)
|
||||
{
|
||||
if (cmd.Length != 3)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: threads abort <thread-id>");
|
||||
return;
|
||||
}
|
||||
|
||||
int threadId;
|
||||
if (!int.TryParse(cmd[2], out threadId))
|
||||
{
|
||||
MainConsole.Instance.Output("ERROR: Thread id must be an integer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Watchdog.AbortThread(threadId))
|
||||
MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
|
||||
else
|
||||
MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Console output is only possible if a console has been established.
|
||||
/// That is something that cannot be determined within this class. So
|
||||
/// all attempts to use the console MUST be verified.
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
protected void Notice(string msg)
|
||||
{
|
||||
if (m_console != null)
|
||||
{
|
||||
m_console.Output(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Console output is only possible if a console has been established.
|
||||
/// That is something that cannot be determined within this class. So
|
||||
/// all attempts to use the console MUST be verified.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="components"></param>
|
||||
protected void Notice(string format, params object[] components)
|
||||
{
|
||||
if (m_console != null)
|
||||
m_console.OutputFormat(format, components);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,12 @@ using HttpServer;
|
||||
using HttpServer.FormDecoders;
|
||||
using NUnit.Framework;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Servers.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class OSHttpTests
|
||||
public class OSHttpTests : OpenSimTestCase
|
||||
{
|
||||
// we need an IHttpClientContext for our tests
|
||||
public class TestHttpClientContext: IHttpClientContext
|
||||
|
||||
@@ -29,11 +29,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Servers.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class VersionInfoTests
|
||||
public class VersionInfoTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestVersionLength()
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenSim
|
||||
public class VersionInfo
|
||||
{
|
||||
private const string VERSION_NUMBER = "0.7.4";
|
||||
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
|
||||
private const Flavour VERSION_FLAVOUR = Flavour.Extended;
|
||||
|
||||
public enum Flavour
|
||||
{
|
||||
|
||||
@@ -35,10 +35,12 @@ using OpenMetaverse;
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// A dictionary for task inventory.
|
||||
/// A dictionary containing task inventory items. Indexed by item UUID.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before
|
||||
/// iterating over it.
|
||||
/// </remarks>
|
||||
public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>,
|
||||
ICloneable, IXmlSerializable
|
||||
{
|
||||
|
||||
@@ -73,9 +73,6 @@ namespace OpenSim.Framework
|
||||
|
||||
private bool _ownerChanged = false;
|
||||
|
||||
// This used ONLY during copy. It can't be relied on at other times!
|
||||
private bool _scriptRunning = true;
|
||||
|
||||
public UUID AssetID {
|
||||
get {
|
||||
return _assetID;
|
||||
@@ -353,14 +350,13 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public bool ScriptRunning {
|
||||
get {
|
||||
return _scriptRunning;
|
||||
}
|
||||
set {
|
||||
_scriptRunning = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This used ONLY during copy. It can't be relied on at other times!
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now.
|
||||
/// </remarks>
|
||||
public bool ScriptRunning { get; set; }
|
||||
|
||||
// See ICloneable
|
||||
|
||||
@@ -388,6 +384,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public TaskInventoryItem()
|
||||
{
|
||||
ScriptRunning = true;
|
||||
CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,17 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using NUnit.Framework;
|
||||
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AgentCircuitDataTest
|
||||
public class AgentCircuitDataTest : OpenSimTestCase
|
||||
{
|
||||
private UUID AgentId;
|
||||
private AvatarAppearance AvAppearance;
|
||||
|
||||
@@ -38,7 +38,7 @@ using Animation = OpenSim.Framework.Animation;
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AnimationTests
|
||||
public class AnimationTests : OpenSimTestCase
|
||||
{
|
||||
private Animation anim1 = null;
|
||||
private Animation anim2 = null;
|
||||
|
||||
@@ -30,11 +30,12 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AssetBaseTest
|
||||
public class AssetBaseTest : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestContainsReferences()
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CacheTests
|
||||
public class CacheTests : OpenSimTestCase
|
||||
{
|
||||
private Cache cache;
|
||||
private UUID cacheItemUUID;
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
*/
|
||||
|
||||
using NUnit.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LocationTest
|
||||
public class LocationTest : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void locationRegionHandleRegionHandle()
|
||||
|
||||
@@ -32,11 +32,12 @@ using OpenMetaverse.StructuredData;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class MundaneFrameworkTests
|
||||
public class MundaneFrameworkTests : OpenSimTestCase
|
||||
{
|
||||
private bool m_RegionSettingsOnSaveEventFired;
|
||||
private bool m_RegionLightShareDataOnSaveEventFired;
|
||||
@@ -302,10 +303,6 @@ namespace OpenSim.Framework.Tests
|
||||
Culture.SetCurrentCulture();
|
||||
Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,11 +31,12 @@ using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PrimeNumberHelperTests
|
||||
public class PrimeNumberHelperTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestGetPrime()
|
||||
|
||||
@@ -33,7 +33,7 @@ using OpenSim.Tests.Common;
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class UtilTests
|
||||
public class UtilTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void VectorOperationTests()
|
||||
|
||||
@@ -47,9 +47,6 @@ namespace OpenSim.Framework
|
||||
Texture = 5,
|
||||
/// <summary>Non-texture assets</summary>
|
||||
Asset = 6,
|
||||
/// <summary>Avatar and primitive data</summary>
|
||||
/// <remarks>This is a sub-category of Task</remarks>
|
||||
State = 7,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
@@ -61,6 +58,5 @@ namespace OpenSim.Framework
|
||||
Task = 1 << 3,
|
||||
Texture = 1 << 4,
|
||||
Asset = 1 << 5,
|
||||
State = 1 << 6,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,6 +533,19 @@ namespace OpenSim.Framework
|
||||
return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a point is inside a bounding box.
|
||||
/// </summary>
|
||||
/// <param name='v'></param>
|
||||
/// <param name='min'></param>
|
||||
/// <param name='max'></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max)
|
||||
{
|
||||
return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z
|
||||
&& v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Are the co-ordinates of the new region visible from the old region?
|
||||
/// </summary>
|
||||
@@ -850,6 +863,12 @@ namespace OpenSim.Framework
|
||||
return Math.Min(Math.Max(x, min), max);
|
||||
}
|
||||
|
||||
public static Vector3 Clip(Vector3 vec, float min, float max)
|
||||
{
|
||||
return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max),
|
||||
Clip(vec.Z, min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert an UUID to a raw uuid string. Right now this is a string without hyphens.
|
||||
/// </summary>
|
||||
@@ -1001,6 +1020,38 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy data from one stream to another, leaving the read position of both streams at the beginning.
|
||||
/// </summary>
|
||||
/// <param name='inputStream'>
|
||||
/// Input stream. Must be seekable.
|
||||
/// </param>
|
||||
/// <exception cref='ArgumentException'>
|
||||
/// Thrown if the input stream is not seekable.
|
||||
/// </exception>
|
||||
public static Stream Copy(Stream inputStream)
|
||||
{
|
||||
if (!inputStream.CanSeek)
|
||||
throw new ArgumentException("Util.Copy(Stream inputStream) must receive an inputStream that can seek");
|
||||
|
||||
const int readSize = 256;
|
||||
byte[] buffer = new byte[readSize];
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
int count = inputStream.Read(buffer, 0, readSize);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
ms.Write(buffer, 0, count);
|
||||
count = inputStream.Read(buffer, 0, readSize);
|
||||
}
|
||||
|
||||
ms.Position = 0;
|
||||
inputStream.Position = 0;
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
||||
public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args)
|
||||
{
|
||||
return SendXmlRpcCommand(url, methodName, args);
|
||||
@@ -1588,7 +1639,13 @@ namespace OpenSim.Framework
|
||||
if (m_ThreadPool != null)
|
||||
throw new InvalidOperationException("SmartThreadPool is already initialized");
|
||||
|
||||
m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
|
||||
STPStartInfo startInfo = new STPStartInfo();
|
||||
startInfo.ThreadPoolName = "Util";
|
||||
startInfo.IdleTimeout = 2000;
|
||||
startInfo.MaxWorkerThreads = maxThreads;
|
||||
startInfo.MinWorkerThreads = 2;
|
||||
|
||||
m_ThreadPool = new SmartThreadPool(startInfo);
|
||||
}
|
||||
|
||||
public static int FireAndForgetCount()
|
||||
@@ -1661,7 +1718,7 @@ namespace OpenSim.Framework
|
||||
break;
|
||||
case FireAndForgetMethod.SmartThreadPool:
|
||||
if (m_ThreadPool == null)
|
||||
m_ThreadPool = new SmartThreadPool(2000, 15, 2);
|
||||
InitThreadPool(15);
|
||||
m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { realCallback, obj });
|
||||
break;
|
||||
case FireAndForgetMethod.Thread:
|
||||
@@ -1690,12 +1747,16 @@ namespace OpenSim.Framework
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
|
||||
{
|
||||
threadPoolUsed = "SmartThreadPool";
|
||||
maxThreads = m_ThreadPool.MaxThreads;
|
||||
minThreads = m_ThreadPool.MinThreads;
|
||||
inUseThreads = m_ThreadPool.InUseThreads;
|
||||
allocatedThreads = m_ThreadPool.ActiveThreads;
|
||||
waitingCallbacks = m_ThreadPool.WaitingCallbacks;
|
||||
// ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool.
|
||||
if (m_ThreadPool != null)
|
||||
{
|
||||
threadPoolUsed = "SmartThreadPool";
|
||||
maxThreads = m_ThreadPool.MaxThreads;
|
||||
minThreads = m_ThreadPool.MinThreads;
|
||||
inUseThreads = m_ThreadPool.InUseThreads;
|
||||
allocatedThreads = m_ThreadPool.ActiveThreads;
|
||||
waitingCallbacks = m_ThreadPool.WaitingCallbacks;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem
|
||||
|
||||
@@ -53,10 +53,18 @@ namespace OpenSim.Framework
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Control the printing of certain debug messages.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged.
|
||||
/// </remarks>
|
||||
public static int DebugLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Request number for diagnostic purposes.
|
||||
/// </summary>
|
||||
public static int RequestNumber = 0;
|
||||
public static int RequestNumber { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// this is the header field used to communicate the local request id
|
||||
@@ -146,7 +154,11 @@ namespace OpenSim.Framework
|
||||
private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
|
||||
{
|
||||
int reqnum = RequestNumber++;
|
||||
// m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method);
|
||||
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})",
|
||||
reqnum, method, url, timeout, compressed);
|
||||
|
||||
string errorMessage = "unknown error";
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
@@ -229,7 +241,7 @@ namespace OpenSim.Framework
|
||||
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
|
||||
if (tickdiff > LongCallTime)
|
||||
m_log.InfoFormat(
|
||||
"[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
"[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
reqnum,
|
||||
method,
|
||||
url,
|
||||
@@ -238,10 +250,14 @@ namespace OpenSim.Framework
|
||||
strBuffer != null
|
||||
? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
|
||||
: "");
|
||||
else if (DebugLevel >= 4)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
|
||||
reqnum, tickdiff, tickdata);
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage);
|
||||
"[WEB UTIL]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage);
|
||||
|
||||
return ErrorResponseMap(errorMessage);
|
||||
}
|
||||
@@ -317,7 +333,11 @@ namespace OpenSim.Framework
|
||||
{
|
||||
int reqnum = RequestNumber++;
|
||||
string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
|
||||
// m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method);
|
||||
|
||||
if (DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})",
|
||||
reqnum, method, url, timeout);
|
||||
|
||||
string errorMessage = "unknown error";
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
@@ -380,7 +400,7 @@ namespace OpenSim.Framework
|
||||
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
|
||||
if (tickdiff > LongCallTime)
|
||||
m_log.InfoFormat(
|
||||
"[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
"[WEB UTIL]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
reqnum,
|
||||
method,
|
||||
url,
|
||||
@@ -389,9 +409,13 @@ namespace OpenSim.Framework
|
||||
queryString != null
|
||||
? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString
|
||||
: "");
|
||||
else if (DebugLevel >= 4)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
|
||||
reqnum, tickdiff, tickdata);
|
||||
}
|
||||
|
||||
m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage);
|
||||
m_log.WarnFormat("[WEB UTIL]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage);
|
||||
|
||||
return ErrorResponseMap(errorMessage);
|
||||
}
|
||||
@@ -643,7 +667,6 @@ namespace OpenSim.Framework
|
||||
/// <returns></returns>
|
||||
public static string[] GetPreferredImageTypes(string accept)
|
||||
{
|
||||
|
||||
if (accept == null || accept == string.Empty)
|
||||
return new string[0];
|
||||
|
||||
@@ -695,13 +718,15 @@ namespace OpenSim.Framework
|
||||
string requestUrl, TRequest obj, Action<TResponse> action)
|
||||
{
|
||||
int reqnum = WebUtil.RequestNumber++;
|
||||
// m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method);
|
||||
|
||||
if (WebUtil.DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}",
|
||||
reqnum, verb, requestUrl);
|
||||
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
int tickdata = 0;
|
||||
|
||||
// m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl);
|
||||
|
||||
Type type = typeof(TRequest);
|
||||
|
||||
WebRequest request = WebRequest.Create(requestUrl);
|
||||
@@ -854,7 +879,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
"[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
reqnum,
|
||||
verb,
|
||||
requestUrl,
|
||||
@@ -862,6 +887,12 @@ namespace OpenSim.Framework
|
||||
tickdata,
|
||||
originalRequest);
|
||||
}
|
||||
else if (WebUtil.DebugLevel >= 4)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
|
||||
reqnum, tickdiff, tickdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,7 +913,11 @@ namespace OpenSim.Framework
|
||||
public static string MakeRequest(string verb, string requestUrl, string obj)
|
||||
{
|
||||
int reqnum = WebUtil.RequestNumber++;
|
||||
// m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method);
|
||||
|
||||
if (WebUtil.DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}",
|
||||
reqnum, verb, requestUrl);
|
||||
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
int tickdata = 0;
|
||||
@@ -967,13 +1002,17 @@ namespace OpenSim.Framework
|
||||
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
|
||||
if (tickdiff > WebUtil.LongCallTime)
|
||||
m_log.InfoFormat(
|
||||
"[FORMS]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
"[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
reqnum,
|
||||
verb,
|
||||
requestUrl,
|
||||
tickdiff,
|
||||
tickdata,
|
||||
obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj);
|
||||
else if (WebUtil.DebugLevel >= 4)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
|
||||
reqnum, tickdiff, tickdata);
|
||||
|
||||
return respstring;
|
||||
}
|
||||
@@ -998,7 +1037,11 @@ namespace OpenSim.Framework
|
||||
public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj)
|
||||
{
|
||||
int reqnum = WebUtil.RequestNumber++;
|
||||
// m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method);
|
||||
|
||||
if (WebUtil.DebugLevel >= 3)
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}",
|
||||
reqnum, verb, requestUrl);
|
||||
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
int tickdata = 0;
|
||||
@@ -1111,7 +1154,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
"[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
|
||||
reqnum,
|
||||
verb,
|
||||
requestUrl,
|
||||
@@ -1119,6 +1162,12 @@ namespace OpenSim.Framework
|
||||
tickdata,
|
||||
originalRequest);
|
||||
}
|
||||
else if (WebUtil.DebugLevel >= 4)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
|
||||
reqnum, tickdiff, tickdata);
|
||||
}
|
||||
|
||||
return deserial;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,6 @@ namespace OpenSim
|
||||
// Make sure command line options take precedence
|
||||
m_config.Source.Merge(argvSource);
|
||||
|
||||
|
||||
IConfig enVars = m_config.Source.Configs["Environment"];
|
||||
|
||||
if( enVars != null )
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
using log4net;
|
||||
using NDesk.Options;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
@@ -81,8 +82,8 @@ namespace OpenSim
|
||||
{
|
||||
base.ReadExtraConfigSettings();
|
||||
|
||||
IConfig startupConfig = m_config.Source.Configs["Startup"];
|
||||
IConfig networkConfig = m_config.Source.Configs["Network"];
|
||||
IConfig startupConfig = Config.Configs["Startup"];
|
||||
IConfig networkConfig = Config.Configs["Network"];
|
||||
|
||||
int stpMaxThreads = 15;
|
||||
|
||||
@@ -105,22 +106,6 @@ namespace OpenSim
|
||||
m_timeInterval = startupConfig.GetInt("timer_Interval", 1200);
|
||||
}
|
||||
|
||||
if (m_logFileAppender != null)
|
||||
{
|
||||
if (m_logFileAppender is log4net.Appender.FileAppender)
|
||||
{
|
||||
log4net.Appender.FileAppender appender =
|
||||
(log4net.Appender.FileAppender)m_logFileAppender;
|
||||
string fileName = startupConfig.GetString("LogFile", String.Empty);
|
||||
if (fileName != String.Empty)
|
||||
{
|
||||
appender.File = fileName;
|
||||
appender.ActivateOptions();
|
||||
}
|
||||
m_log.InfoFormat("[LOGGING]: Logging started to file {0}", appender.File);
|
||||
}
|
||||
}
|
||||
|
||||
string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty);
|
||||
FireAndForgetMethod asyncCallMethod;
|
||||
if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
|
||||
@@ -163,7 +148,7 @@ namespace OpenSim
|
||||
break;
|
||||
case "rest":
|
||||
m_console = new RemoteConsole("Region");
|
||||
((RemoteConsole)m_console).ReadConfig(m_config.Source);
|
||||
((RemoteConsole)m_console).ReadConfig(Config);
|
||||
break;
|
||||
default:
|
||||
m_console = new LocalConsole("Region");
|
||||
@@ -173,6 +158,7 @@ namespace OpenSim
|
||||
|
||||
MainConsole.Instance = m_console;
|
||||
|
||||
RegisterCommonAppenders(Config.Configs["Startup"]);
|
||||
RegisterConsoleCommands();
|
||||
|
||||
base.StartupSpecific();
|
||||
@@ -250,12 +236,6 @@ namespace OpenSim
|
||||
+ "If an avatar name is given then only packets from that avatar are logged",
|
||||
Debug);
|
||||
|
||||
m_console.Commands.AddCommand("Debug", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
|
||||
|
||||
m_console.Commands.AddCommand("Debug", false, "debug scene",
|
||||
"debug scene <scripting> <collisions> <physics>",
|
||||
"Turn on scene debugging", Debug);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "change region",
|
||||
"change region <region name>",
|
||||
"Change current console region", ChangeSelectedRegion);
|
||||
@@ -310,8 +290,11 @@ namespace OpenSim
|
||||
"Change the scale of a named prim", HandleEditScale);
|
||||
|
||||
m_console.Commands.AddCommand("Users", false, "kick user",
|
||||
"kick user <first> <last> [message]",
|
||||
"Kick a user off the simulator", KickUserCommand);
|
||||
"kick user <first> <last> [--force] [message]",
|
||||
"Kick a user off the simulator",
|
||||
"The --force option will kick the user without any checks to see whether it's already in the process of closing\n"
|
||||
+ "Only use this option if you are sure the avatar is inactive and a normal kick user operation does not removed them",
|
||||
KickUserCommand);
|
||||
|
||||
m_console.Commands.AddCommand("Users", false, "show users",
|
||||
"show users [full]",
|
||||
@@ -328,10 +311,6 @@ namespace OpenSim
|
||||
"show circuits",
|
||||
"Show agent circuit data", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("Comms", false, "show http-handlers",
|
||||
"show http-handlers",
|
||||
"Show all registered http handlers", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("Comms", false, "show pending-objects",
|
||||
"show pending-objects",
|
||||
"Show # of objects on the pending queues of all scene viewers", HandleShow);
|
||||
@@ -365,26 +344,6 @@ namespace OpenSim
|
||||
"restart",
|
||||
"Restart all sims in this instance", RunCommand);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "config set",
|
||||
"config set <section> <key> <value>",
|
||||
"Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "config get",
|
||||
"config get [<section>] [<key>]",
|
||||
"Synonym for config show",
|
||||
HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "config show",
|
||||
"config show [<section>] [<key>]",
|
||||
"Show config information",
|
||||
"If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
|
||||
+ "If a section is given but not a field, then all fields in that section are printed.",
|
||||
HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "config save",
|
||||
"config save <path>",
|
||||
"Save current configuration to a file at the given path", HandleConfig);
|
||||
|
||||
m_console.Commands.AddCommand("General", false, "command-script",
|
||||
"command-script <script>",
|
||||
"Run a command script from file", RunCommand);
|
||||
@@ -453,11 +412,17 @@ namespace OpenSim
|
||||
/// <param name="cmdparams">name of avatar to kick</param>
|
||||
private void KickUserCommand(string module, string[] cmdparams)
|
||||
{
|
||||
if (cmdparams.Length < 4)
|
||||
bool force = false;
|
||||
|
||||
OptionSet options = new OptionSet().Add("f|force", delegate (string v) { force = v != null; });
|
||||
|
||||
List<string> mainParams = options.Parse(cmdparams);
|
||||
|
||||
if (mainParams.Count < 4)
|
||||
return;
|
||||
|
||||
string alert = null;
|
||||
if (cmdparams.Length > 4)
|
||||
if (mainParams.Count > 4)
|
||||
alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
|
||||
|
||||
IList agents = SceneManager.GetCurrentSceneAvatars();
|
||||
@@ -466,8 +431,8 @@ namespace OpenSim
|
||||
{
|
||||
RegionInfo regionInfo = presence.Scene.RegionInfo;
|
||||
|
||||
if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) &&
|
||||
presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
|
||||
if (presence.Firstname.ToLower().Contains(mainParams[2].ToLower()) &&
|
||||
presence.Lastname.ToLower().Contains(mainParams[3].ToLower()))
|
||||
{
|
||||
MainConsole.Instance.Output(
|
||||
String.Format(
|
||||
@@ -480,42 +445,13 @@ namespace OpenSim
|
||||
else
|
||||
presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
|
||||
|
||||
presence.Scene.IncomingCloseAgent(presence.UUID);
|
||||
presence.Scene.IncomingCloseAgent(presence.UUID, force);
|
||||
}
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output("");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an optional startup list of commands
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
private void RunCommandScript(string fileName)
|
||||
{
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
m_log.Info("[COMMANDFILE]: Running " + fileName);
|
||||
|
||||
using (StreamReader readFile = File.OpenText(fileName))
|
||||
{
|
||||
string currentCommand;
|
||||
while ((currentCommand = readFile.ReadLine()) != null)
|
||||
{
|
||||
currentCommand = currentCommand.Trim();
|
||||
if (!(currentCommand == ""
|
||||
|| currentCommand.StartsWith(";")
|
||||
|| currentCommand.StartsWith("//")
|
||||
|| currentCommand.StartsWith("#")))
|
||||
{
|
||||
m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
|
||||
m_console.RunCommand(currentCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a file and uses it as input to the console command parser.
|
||||
/// </summary>
|
||||
@@ -620,111 +556,9 @@ namespace OpenSim
|
||||
bool changed = PopulateRegionEstateInfo(regInfo);
|
||||
IScene scene;
|
||||
CreateRegion(regInfo, true, out scene);
|
||||
|
||||
if (changed)
|
||||
regInfo.EstateSettings.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change and load configuration file data.
|
||||
/// </summary>
|
||||
/// <param name="module"></param>
|
||||
/// <param name="cmd"></param>
|
||||
private void HandleConfig(string module, string[] cmd)
|
||||
{
|
||||
List<string> args = new List<string>(cmd);
|
||||
args.RemoveAt(0);
|
||||
string[] cmdparams = args.ToArray();
|
||||
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
string firstParam = cmdparams[0].ToLower();
|
||||
|
||||
switch (firstParam)
|
||||
{
|
||||
case "set":
|
||||
if (cmdparams.Length < 4)
|
||||
{
|
||||
Notice("Syntax: config set <section> <key> <value>");
|
||||
Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
|
||||
}
|
||||
else
|
||||
{
|
||||
IConfig c;
|
||||
IConfigSource source = new IniConfigSource();
|
||||
c = source.AddConfig(cmdparams[1]);
|
||||
if (c != null)
|
||||
{
|
||||
string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
|
||||
c.Set(cmdparams[2], _value);
|
||||
m_config.Source.Merge(source);
|
||||
|
||||
Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "get":
|
||||
case "show":
|
||||
if (cmdparams.Length == 1)
|
||||
{
|
||||
foreach (IConfig config in m_config.Source.Configs)
|
||||
{
|
||||
Notice("[{0}]", config.Name);
|
||||
string[] keys = config.GetKeys();
|
||||
foreach (string key in keys)
|
||||
Notice(" {0} = {1}", key, config.GetString(key));
|
||||
}
|
||||
}
|
||||
else if (cmdparams.Length == 2 || cmdparams.Length == 3)
|
||||
{
|
||||
IConfig config = m_config.Source.Configs[cmdparams[1]];
|
||||
if (config == null)
|
||||
{
|
||||
Notice("Section \"{0}\" does not exist.",cmdparams[1]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cmdparams.Length == 2)
|
||||
{
|
||||
Notice("[{0}]", config.Name);
|
||||
foreach (string key in config.GetKeys())
|
||||
Notice(" {0} = {1}", key, config.GetString(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
Notice(
|
||||
"config get {0} {1} : {2}",
|
||||
cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
|
||||
Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "save":
|
||||
if (cmdparams.Length < 2)
|
||||
{
|
||||
Notice("Syntax: config save <path>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.iniFilePath == cmdparams[1])
|
||||
{
|
||||
Notice("Path can not be " + Application.iniFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
Notice("Saving configuration file: " + cmdparams[1]);
|
||||
m_config.Save(cmdparams[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
regInfo.EstateSettings.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -793,13 +627,6 @@ namespace OpenSim
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case "command-script":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
RunCommandScript(cmdparams[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
case "backup":
|
||||
MainConsole.Instance.Output("Triggering save of pending object updates to persistent store");
|
||||
SceneManager.BackupCurrentScene();
|
||||
@@ -843,12 +670,20 @@ namespace OpenSim
|
||||
|
||||
if (!SceneManager.TrySetCurrentScene(newRegionName))
|
||||
MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName));
|
||||
else
|
||||
RefreshPrompt();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: change region <region name>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshs prompt with the current selection details.
|
||||
/// </summary>
|
||||
private void RefreshPrompt()
|
||||
{
|
||||
string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName);
|
||||
MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName));
|
||||
|
||||
@@ -870,6 +705,18 @@ namespace OpenSim
|
||||
m_console.ConsoleScene = SceneManager.CurrentScene;
|
||||
}
|
||||
|
||||
protected override void HandleRestartRegion(RegionInfo whichRegion)
|
||||
{
|
||||
base.HandleRestartRegion(whichRegion);
|
||||
|
||||
// Where we are restarting multiple scenes at once, a previous call to RefreshPrompt may have set the
|
||||
// m_console.ConsoleScene to null (indicating all scenes).
|
||||
if (m_console.ConsoleScene != null && whichRegion.RegionName == ((Scene)m_console.ConsoleScene).Name)
|
||||
SceneManager.TrySetCurrentScene(whichRegion.RegionName);
|
||||
|
||||
RefreshPrompt();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turn on some debugging values for OpenSim.
|
||||
/// </summary>
|
||||
@@ -903,30 +750,6 @@ namespace OpenSim
|
||||
|
||||
break;
|
||||
|
||||
case "scene":
|
||||
if (args.Length == 4)
|
||||
{
|
||||
if (SceneManager.CurrentScene == null)
|
||||
{
|
||||
MainConsole.Instance.Output("Please use 'change region <regioname>' first");
|
||||
}
|
||||
else
|
||||
{
|
||||
string key = args[2];
|
||||
string value = args[3];
|
||||
SceneManager.CurrentScene.SetSceneCoreDebug(
|
||||
new Dictionary<string, string>() { { key, value } });
|
||||
|
||||
MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug scene scripting|collisions|physics|teleport true|false");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
MainConsole.Instance.Output("Unknown debug command");
|
||||
break;
|
||||
@@ -1002,33 +825,6 @@ namespace OpenSim
|
||||
HandleShowCircuits();
|
||||
break;
|
||||
|
||||
case "http-handlers":
|
||||
System.Text.StringBuilder handlers = new System.Text.StringBuilder("Registered HTTP Handlers:\n");
|
||||
|
||||
handlers.AppendFormat("* XMLRPC:\n");
|
||||
foreach (String s in HttpServer.GetXmlRpcHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* HTTP:\n");
|
||||
List<String> poll = HttpServer.GetPollServiceHandlerKeys();
|
||||
foreach (String s in HttpServer.GetHTTPHandlerKeys())
|
||||
handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
|
||||
|
||||
handlers.AppendFormat("* Agent:\n");
|
||||
foreach (String s in HttpServer.GetAgentHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* LLSD:\n");
|
||||
foreach (String s in HttpServer.GetLLSDHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
handlers.AppendFormat("* StreamHandlers ({0}):\n", HttpServer.GetStreamHandlerKeys().Count);
|
||||
foreach (String s in HttpServer.GetStreamHandlerKeys())
|
||||
handlers.AppendFormat("\t{0}\n", s);
|
||||
|
||||
MainConsole.Instance.Output(handlers.ToString());
|
||||
break;
|
||||
|
||||
case "modules":
|
||||
MainConsole.Instance.Output("The currently loaded shared modules are:");
|
||||
foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
|
||||
@@ -1123,7 +919,7 @@ namespace OpenSim
|
||||
aCircuit.Name,
|
||||
aCircuit.child ? "child" : "root",
|
||||
aCircuit.circuitcode.ToString(),
|
||||
aCircuit.IPAddress.ToString(),
|
||||
aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set",
|
||||
aCircuit.Viewer);
|
||||
});
|
||||
|
||||
|
||||
@@ -100,13 +100,7 @@ namespace OpenSim
|
||||
/// <value>
|
||||
/// The config information passed into the OpenSimulator region server.
|
||||
/// </value>
|
||||
public OpenSimConfigSource ConfigSource
|
||||
{
|
||||
get { return m_config; }
|
||||
set { m_config = value; }
|
||||
}
|
||||
|
||||
protected OpenSimConfigSource m_config;
|
||||
public OpenSimConfigSource ConfigSource { get; private set; }
|
||||
|
||||
public List<IClientNetworkServer> ClientServers
|
||||
{
|
||||
@@ -154,13 +148,14 @@ namespace OpenSim
|
||||
protected virtual void LoadConfigSettings(IConfigSource configSource)
|
||||
{
|
||||
m_configLoader = new ConfigurationLoader();
|
||||
m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
|
||||
ConfigSource = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
|
||||
Config = ConfigSource.Source;
|
||||
ReadExtraConfigSettings();
|
||||
}
|
||||
|
||||
protected virtual void ReadExtraConfigSettings()
|
||||
{
|
||||
IConfig networkConfig = m_config.Source.Configs["Network"];
|
||||
IConfig networkConfig = Config.Configs["Network"];
|
||||
if (networkConfig != null)
|
||||
{
|
||||
proxyUrl = networkConfig.GetString("proxy_url", "");
|
||||
@@ -193,7 +188,7 @@ namespace OpenSim
|
||||
/// </summary>
|
||||
protected override void StartupSpecific()
|
||||
{
|
||||
IConfig startupConfig = m_config.Source.Configs["Startup"];
|
||||
IConfig startupConfig = Config.Configs["Startup"];
|
||||
if (startupConfig != null)
|
||||
{
|
||||
string pidFile = startupConfig.GetString("PIDFile", String.Empty);
|
||||
@@ -204,29 +199,41 @@ namespace OpenSim
|
||||
}
|
||||
|
||||
// Load the simulation data service
|
||||
IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"];
|
||||
IConfig simDataConfig = Config.Configs["SimulationDataStore"];
|
||||
if (simDataConfig == null)
|
||||
throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
|
||||
|
||||
string module = simDataConfig.GetString("LocalServiceModule", String.Empty);
|
||||
if (String.IsNullOrEmpty(module))
|
||||
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section.");
|
||||
m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source });
|
||||
|
||||
m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { Config });
|
||||
if (m_simulationDataService == null)
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.",
|
||||
module));
|
||||
|
||||
// Load the estate data service
|
||||
IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"];
|
||||
IConfig estateDataConfig = Config.Configs["EstateDataStore"];
|
||||
if (estateDataConfig == null)
|
||||
throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
|
||||
|
||||
module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
|
||||
if (String.IsNullOrEmpty(module))
|
||||
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
|
||||
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source });
|
||||
|
||||
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
|
||||
if (m_estateDataService == null)
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
|
||||
module));
|
||||
|
||||
base.StartupSpecific();
|
||||
|
||||
m_stats = StatsManager.SimExtraStats;
|
||||
|
||||
// Create a ModuleLoader instance
|
||||
m_moduleLoader = new ModuleLoader(m_config.Source);
|
||||
m_moduleLoader = new ModuleLoader(Config);
|
||||
|
||||
LoadPlugins();
|
||||
foreach (IApplicationPlugin plugin in m_plugins)
|
||||
@@ -234,51 +241,51 @@ namespace OpenSim
|
||||
plugin.PostInitialise();
|
||||
}
|
||||
|
||||
AddPluginCommands();
|
||||
}
|
||||
|
||||
protected virtual void AddPluginCommands()
|
||||
{
|
||||
// If console exists add plugin commands.
|
||||
if (m_console != null)
|
||||
{
|
||||
List<string> topics = GetHelpTopics();
|
||||
StatsManager.RegisterConsoleCommands(m_console);
|
||||
AddPluginCommands(m_console);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string topic in topics)
|
||||
protected virtual void AddPluginCommands(ICommandConsole console)
|
||||
{
|
||||
List<string> topics = GetHelpTopics();
|
||||
|
||||
foreach (string topic in topics)
|
||||
{
|
||||
string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
|
||||
|
||||
// This is a hack to allow the user to enter the help command in upper or lowercase. This will go
|
||||
// away at some point.
|
||||
console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
|
||||
"help " + capitalizedTopic,
|
||||
"Get help on plugin command '" + topic + "'",
|
||||
HandleCommanderHelp);
|
||||
console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
|
||||
"help " + capitalizedTopic,
|
||||
"Get help on plugin command '" + topic + "'",
|
||||
HandleCommanderHelp);
|
||||
|
||||
ICommander commander = null;
|
||||
|
||||
Scene s = SceneManager.CurrentOrFirstScene;
|
||||
|
||||
if (s != null && s.GetCommanders() != null)
|
||||
{
|
||||
string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
|
||||
if (s.GetCommanders().ContainsKey(topic))
|
||||
commander = s.GetCommanders()[topic];
|
||||
}
|
||||
|
||||
// This is a hack to allow the user to enter the help command in upper or lowercase. This will go
|
||||
// away at some point.
|
||||
m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
|
||||
"help " + capitalizedTopic,
|
||||
"Get help on plugin command '" + topic + "'",
|
||||
HandleCommanderHelp);
|
||||
m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
|
||||
"help " + capitalizedTopic,
|
||||
"Get help on plugin command '" + topic + "'",
|
||||
HandleCommanderHelp);
|
||||
if (commander == null)
|
||||
continue;
|
||||
|
||||
ICommander commander = null;
|
||||
|
||||
Scene s = SceneManager.CurrentOrFirstScene;
|
||||
|
||||
if (s != null && s.GetCommanders() != null)
|
||||
{
|
||||
if (s.GetCommanders().ContainsKey(topic))
|
||||
commander = s.GetCommanders()[topic];
|
||||
}
|
||||
|
||||
if (commander == null)
|
||||
continue;
|
||||
|
||||
foreach (string command in commander.Commands.Keys)
|
||||
{
|
||||
m_console.Commands.AddCommand(capitalizedTopic, false,
|
||||
topic + " " + command,
|
||||
topic + " " + commander.Commands[command].ShortHelp(),
|
||||
String.Empty, HandleCommanderCommand);
|
||||
}
|
||||
foreach (string command in commander.Commands.Keys)
|
||||
{
|
||||
console.Commands.AddCommand(capitalizedTopic, false,
|
||||
topic + " " + command,
|
||||
topic + " " + commander.Commands[command].ShortHelp(),
|
||||
String.Empty, HandleCommanderCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,10 +310,15 @@ namespace OpenSim
|
||||
// Called from base.StartUp()
|
||||
|
||||
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
|
||||
SceneManager.OnRestartSim += handleRestartRegion;
|
||||
SceneManager.OnRestartSim += HandleRestartRegion;
|
||||
|
||||
// Only start the memory watchdog once all regions are ready
|
||||
SceneManager.OnRegionsReadyStatusChange += sm => MemoryWatchdog.Enabled = sm.AllRegionsReady;
|
||||
// Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is
|
||||
// heavily used during initial startup.
|
||||
//
|
||||
// FIXME: It's also possible that region ready status should be flipped during an OAR load since this
|
||||
// also makes heavy use of the CPU.
|
||||
SceneManager.OnRegionsReadyStatusChange
|
||||
+= sm => { MemoryWatchdog.Enabled = sm.AllRegionsReady; Watchdog.Enabled = sm.AllRegionsReady; };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -363,7 +375,7 @@ namespace OpenSim
|
||||
}
|
||||
|
||||
IClientNetworkServer clientServer;
|
||||
Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer);
|
||||
Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
|
||||
|
||||
m_log.Info("[MODULES]: Loading Region's modules (old style)");
|
||||
|
||||
@@ -458,10 +470,10 @@ namespace OpenSim
|
||||
string estateOwnerPassword = null;
|
||||
string rawEstateOwnerUuid = null;
|
||||
|
||||
if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
|
||||
if (Config.Configs[ESTATE_SECTION_NAME] != null)
|
||||
{
|
||||
string defaultEstateOwnerName
|
||||
= m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
|
||||
= Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
|
||||
string[] ownerNames = defaultEstateOwnerName.Split(' ');
|
||||
|
||||
if (ownerNames.Length >= 2)
|
||||
@@ -471,9 +483,9 @@ namespace OpenSim
|
||||
}
|
||||
|
||||
// Info to be used only on Standalone Mode
|
||||
rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
|
||||
estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
|
||||
estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
|
||||
rawEstateOwnerUuid = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
|
||||
estateOwnerEMail = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
|
||||
estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
|
||||
}
|
||||
|
||||
MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
|
||||
@@ -540,7 +552,7 @@ namespace OpenSim
|
||||
if (account == null)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
|
||||
"[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -720,7 +732,7 @@ namespace OpenSim
|
||||
return new Scene(
|
||||
regionInfo, circuitManager, sceneGridService,
|
||||
simDataService, estateDataService, m_moduleLoader, false,
|
||||
m_config.Source, m_version);
|
||||
Config, m_version);
|
||||
}
|
||||
|
||||
protected void ShutdownClientServer(RegionInfo whichRegion)
|
||||
@@ -747,9 +759,11 @@ namespace OpenSim
|
||||
}
|
||||
}
|
||||
|
||||
public void handleRestartRegion(RegionInfo whichRegion)
|
||||
protected virtual void HandleRestartRegion(RegionInfo whichRegion)
|
||||
{
|
||||
m_log.Info("[OPENSIM]: Got restart signal from SceneManager");
|
||||
m_log.InfoFormat(
|
||||
"[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
|
||||
whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
|
||||
|
||||
ShutdownClientServer(whichRegion);
|
||||
IScene scene;
|
||||
@@ -761,7 +775,7 @@ namespace OpenSim
|
||||
protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
|
||||
{
|
||||
return GetPhysicsScene(
|
||||
m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier);
|
||||
m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -895,7 +909,6 @@ namespace OpenSim
|
||||
m_log.Info("[SHUTDOWN]: Closing all threads");
|
||||
m_log.Info("[SHUTDOWN]: Killing listener thread");
|
||||
m_log.Info("[SHUTDOWN]: Killing clients");
|
||||
// TODO: implement this
|
||||
m_log.Info("[SHUTDOWN]: Closing console and terminating");
|
||||
|
||||
try
|
||||
@@ -904,7 +917,7 @@ namespace OpenSim
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e);
|
||||
m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,9 +1011,9 @@ namespace OpenSim
|
||||
|
||||
string defaultEstateName = null;
|
||||
|
||||
if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
|
||||
if (Config.Configs[ESTATE_SECTION_NAME] != null)
|
||||
{
|
||||
defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
|
||||
defaultEstateName = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
|
||||
|
||||
if (defaultEstateName != null)
|
||||
{
|
||||
@@ -1083,28 +1096,14 @@ namespace OpenSim
|
||||
MainConsole.Instance.Output("Joining the estate failed. Please try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true; // need to update the database
|
||||
}
|
||||
return true; // need to update the database
|
||||
}
|
||||
}
|
||||
|
||||
public class OpenSimConfigSource
|
||||
{
|
||||
public IConfigSource Source;
|
||||
|
||||
public void Save(string path)
|
||||
{
|
||||
if (Source is IniConfigSource)
|
||||
{
|
||||
IniConfigSource iniCon = (IniConfigSource) Source;
|
||||
iniCon.Save(path);
|
||||
}
|
||||
else if (Source is XmlConfigSource)
|
||||
{
|
||||
XmlConfigSource xmlCon = (XmlConfigSource) Source;
|
||||
xmlCon.Save(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
// private static readonly string m_fetchInventoryPath = "0006/";
|
||||
private static readonly string m_copyFromNotecardPath = "0007/";
|
||||
// private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
|
||||
|
||||
|
||||
private static readonly string m_UpdateAgentInformationPath = "0500/";
|
||||
|
||||
// These are callbacks which will be setup by the scene so that we can update scene data when we
|
||||
// receive capability calls
|
||||
public NewInventoryItem AddNewInventoryItem = null;
|
||||
@@ -163,8 +163,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
m_HostCapsObj.RegisterHandler(
|
||||
"SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest, "SEED", null));
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID);
|
||||
// m_log.DebugFormat(
|
||||
// "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID);
|
||||
|
||||
//m_capsHandlers["MapLayer"] =
|
||||
// new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST",
|
||||
@@ -204,6 +204,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req);
|
||||
m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
|
||||
m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
|
||||
IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation);
|
||||
m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler);
|
||||
|
||||
m_HostCapsObj.RegisterHandler(
|
||||
"CopyInventoryFromNotecard",
|
||||
@@ -254,11 +256,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
public string SeedCapRequest(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName);
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID);
|
||||
|
||||
if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint))
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
m_log.WarnFormat(
|
||||
"[CAPS]: Unauthorized CAPS client {0} from {1}",
|
||||
m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint);
|
||||
|
||||
@@ -854,6 +857,22 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
response["int_response_code"] = 200;
|
||||
return LLSDHelpers.SerialiseLLSDReply(response);
|
||||
}
|
||||
|
||||
public string UpdateAgentInformation(string request, string path,
|
||||
string param, IOSHttpRequest httpRequest,
|
||||
IOSHttpResponse httpResponse)
|
||||
{
|
||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
|
||||
OSDMap accessPrefs = new OSDMap();
|
||||
accessPrefs["max"] = "A";
|
||||
|
||||
resp["access_prefs"] = accessPrefs;
|
||||
|
||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public class AssetUploader
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
|
||||
//scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack);
|
||||
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
// scene.EventManager.OnNewClient += OnNewClient;
|
||||
|
||||
// TODO: Leaving these open, or closing them when we
|
||||
// become a child is incorrect. It messes up TP in a big
|
||||
@@ -102,6 +102,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
// circuit is there.
|
||||
|
||||
scene.EventManager.OnClientClosed += ClientClosed;
|
||||
|
||||
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
||||
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
||||
|
||||
@@ -110,10 +111,10 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
false,
|
||||
"debug eq",
|
||||
"debug eq [0|1|2]",
|
||||
"Turn on event queue debugging"
|
||||
+ "<= 0 - turns off all event queue logging"
|
||||
+ ">= 1 - turns on outgoing event logging"
|
||||
+ ">= 2 - turns on poll notification",
|
||||
"Turn on event queue debugging\n"
|
||||
+ " <= 0 - turns off all event queue logging\n"
|
||||
+ " >= 1 - turns on outgoing event logging\n"
|
||||
+ " >= 2 - turns on poll notification",
|
||||
HandleDebugEq);
|
||||
}
|
||||
else
|
||||
@@ -226,16 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
//client.OnLogout += ClientClosed;
|
||||
}
|
||||
|
||||
// private void ClientClosed(IClientAPI client)
|
||||
// {
|
||||
// ClientClosed(client.AgentId);
|
||||
// }
|
||||
|
||||
private void ClientClosed(UUID agentID, Scene scene)
|
||||
{
|
||||
// m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
|
||||
|
||||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock;
|
||||
namespace OpenSim.Region.ClientStack.Linden.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class EventQueueTests
|
||||
public class EventQueueTests : OpenSimTestCase
|
||||
{
|
||||
private TestScene m_scene;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
|
||||
UUID spId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
SceneHelpers.AddScenePresence(m_scene, spId);
|
||||
m_scene.IncomingCloseAgent(spId);
|
||||
m_scene.IncomingCloseAgent(spId, false);
|
||||
|
||||
// TODO: Add more assertions for the other aspects of event queues
|
||||
Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0));
|
||||
|
||||
@@ -45,7 +45,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public Packet Packet;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// No arg constructor.
|
||||
/// </summary>
|
||||
public IncomingPacket() {}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="client">Reference to the client this packet came from</param>
|
||||
/// <param name="packet">Packet data</param>
|
||||
|
||||
@@ -346,7 +346,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
private int m_moneyBalance;
|
||||
private int m_animationSequenceNumber = 1;
|
||||
private bool m_SendLogoutPacketWhenClosing = true;
|
||||
private AgentUpdateArgs lastarg;
|
||||
|
||||
/// <summary>
|
||||
/// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
|
||||
/// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
|
||||
/// is doing absolutely nothing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
|
||||
/// cannot retain a reference to it outside of that method.
|
||||
/// </remarks>
|
||||
private AgentUpdateArgs m_lastAgentUpdateArgs;
|
||||
|
||||
protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
|
||||
protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
|
||||
@@ -487,16 +497,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
#region Client Methods
|
||||
|
||||
/// <summary>
|
||||
/// Close down the client view
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
Close(false);
|
||||
}
|
||||
|
||||
public void Close(bool force)
|
||||
{
|
||||
// We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
|
||||
// a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
|
||||
lock (CloseSyncLock)
|
||||
{
|
||||
if (!IsActive)
|
||||
// We still perform a force close inside the sync lock since this is intended to attempt close where
|
||||
// there is some unidentified connection problem, not where we have issues due to deadlock
|
||||
if (!IsActive && !force)
|
||||
return;
|
||||
|
||||
IsActive = false;
|
||||
@@ -802,8 +816,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
OutPacket(mov, ThrottleOutPacketType.Unknown);
|
||||
}
|
||||
|
||||
public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
|
||||
UUID fromAgentID, byte source, byte audible)
|
||||
public void SendChatMessage(
|
||||
string message, byte type, Vector3 fromPos, string fromName,
|
||||
UUID fromAgentID, UUID ownerID, byte source, byte audible)
|
||||
{
|
||||
ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
|
||||
reply.ChatData.Audible = audible;
|
||||
@@ -812,7 +827,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
reply.ChatData.SourceType = source;
|
||||
reply.ChatData.Position = fromPos;
|
||||
reply.ChatData.FromName = Util.StringToBytes256(fromName);
|
||||
reply.ChatData.OwnerID = fromAgentID;
|
||||
reply.ChatData.OwnerID = ownerID;
|
||||
reply.ChatData.SourceID = fromAgentID;
|
||||
|
||||
OutPacket(reply, ThrottleOutPacketType.Task);
|
||||
@@ -1572,7 +1587,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
|
||||
{
|
||||
OutPacket(kill, ThrottleOutPacketType.State);
|
||||
OutPacket(kill, ThrottleOutPacketType.Task);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3917,7 +3932,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
|
||||
|
||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
||||
ImprovedTerseObjectUpdatePacket packet
|
||||
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
|
||||
|
||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||
packet.RegionData.TimeDilation = timeDilation;
|
||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
||||
@@ -3962,7 +3979,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
|
||||
|
||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
||||
ImprovedTerseObjectUpdatePacket packet
|
||||
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
|
||||
PacketType.ImprovedTerseObjectUpdate);
|
||||
|
||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||
packet.RegionData.TimeDilation = timeDilation;
|
||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
||||
@@ -4447,37 +4467,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
if (bl[i].BannedUserID == UUID.Zero)
|
||||
continue;
|
||||
BannedUsers.Add(bl[i].BannedUserID);
|
||||
|
||||
if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
|
||||
{
|
||||
EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
|
||||
packet.AgentData.TransactionID = UUID.Random();
|
||||
packet.AgentData.AgentID = AgentId;
|
||||
packet.AgentData.SessionID = SessionId;
|
||||
packet.MethodData.Invoice = invoice;
|
||||
packet.MethodData.Method = Utils.StringToBytes("setaccess");
|
||||
|
||||
EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
|
||||
|
||||
int j;
|
||||
for (j = 0; j < (6 + BannedUsers.Count); j++)
|
||||
{
|
||||
returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
|
||||
}
|
||||
j = 0;
|
||||
|
||||
returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
|
||||
foreach (UUID banned in BannedUsers)
|
||||
{
|
||||
returnblock[j].Parameter = banned.GetBytes(); j++;
|
||||
}
|
||||
packet.ParamList = returnblock;
|
||||
packet.Header.Reliable = true;
|
||||
OutPacket(packet, ThrottleOutPacketType.Task);
|
||||
|
||||
BannedUsers.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
|
||||
packet.AgentData.TransactionID = UUID.Random();
|
||||
packet.AgentData.AgentID = AgentId;
|
||||
packet.AgentData.SessionID = SessionId;
|
||||
packet.MethodData.Invoice = invoice;
|
||||
packet.MethodData.Method = Utils.StringToBytes("setaccess");
|
||||
|
||||
EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
|
||||
|
||||
for (int i = 0; i < (6 + BannedUsers.Count); i++)
|
||||
{
|
||||
returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
|
||||
}
|
||||
int j = 0;
|
||||
|
||||
returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
|
||||
returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
|
||||
|
||||
foreach (UUID banned in BannedUsers)
|
||||
{
|
||||
returnblock[j].Parameter = banned.GetBytes(); j++;
|
||||
}
|
||||
packet.ParamList = returnblock;
|
||||
packet.Header.Reliable = false;
|
||||
OutPacket(packet, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
|
||||
@@ -4947,7 +4974,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
|
||||
ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
|
||||
ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
|
||||
= PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
|
||||
|
||||
block.Data = data;
|
||||
|
||||
if (textureEntry != null && textureEntry.Length > 0)
|
||||
@@ -5179,14 +5208,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
protected virtual void RegisterLocalPacketHandlers()
|
||||
{
|
||||
AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
|
||||
|
||||
// If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
|
||||
// for each AgentUpdate packet.
|
||||
AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
|
||||
|
||||
AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
|
||||
AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
|
||||
AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
|
||||
AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
|
||||
AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
|
||||
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false);
|
||||
AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false);
|
||||
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
|
||||
AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
|
||||
AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
|
||||
AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
|
||||
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
|
||||
@@ -5286,9 +5319,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
|
||||
AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
|
||||
AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
|
||||
AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest, false);
|
||||
AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest, false);
|
||||
AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest, false);
|
||||
AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
|
||||
AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
|
||||
AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
|
||||
AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
|
||||
AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
|
||||
AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
|
||||
@@ -5406,80 +5439,83 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
#region Scene/Avatar
|
||||
|
||||
private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
|
||||
private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
|
||||
{
|
||||
if (OnAgentUpdate != null)
|
||||
{
|
||||
bool update = false;
|
||||
AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
|
||||
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
|
||||
|
||||
#region Packet Session and User Check
|
||||
if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
|
||||
if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId)
|
||||
{
|
||||
PacketPool.Instance.ReturnPacket(packet);
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
|
||||
bool update = false;
|
||||
AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
|
||||
|
||||
// We can only check when we have something to check
|
||||
// against.
|
||||
|
||||
if (lastarg != null)
|
||||
if (m_lastAgentUpdateArgs != null)
|
||||
{
|
||||
// These should be ordered from most-likely to
|
||||
// least likely to change. I've made an initial
|
||||
// guess at that.
|
||||
update =
|
||||
(
|
||||
(x.BodyRotation != lastarg.BodyRotation) ||
|
||||
(x.CameraAtAxis != lastarg.CameraAtAxis) ||
|
||||
(x.CameraCenter != lastarg.CameraCenter) ||
|
||||
(x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
|
||||
(x.CameraUpAxis != lastarg.CameraUpAxis) ||
|
||||
(x.ControlFlags != lastarg.ControlFlags) ||
|
||||
(x.Far != lastarg.Far) ||
|
||||
(x.Flags != lastarg.Flags) ||
|
||||
(x.State != lastarg.State) ||
|
||||
(x.HeadRotation != lastarg.HeadRotation) ||
|
||||
(x.SessionID != lastarg.SessionID) ||
|
||||
(x.AgentID != lastarg.AgentID)
|
||||
(x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) ||
|
||||
(x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) ||
|
||||
(x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) ||
|
||||
(x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) ||
|
||||
(x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) ||
|
||||
(x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) ||
|
||||
(x.Far != m_lastAgentUpdateArgs.Far) ||
|
||||
(x.Flags != m_lastAgentUpdateArgs.Flags) ||
|
||||
(x.State != m_lastAgentUpdateArgs.State) ||
|
||||
(x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) ||
|
||||
(x.SessionID != m_lastAgentUpdateArgs.SessionID) ||
|
||||
(x.AgentID != m_lastAgentUpdateArgs.AgentID)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastAgentUpdateArgs = new AgentUpdateArgs();
|
||||
update = true;
|
||||
}
|
||||
|
||||
// These should be ordered from most-likely to
|
||||
// least likely to change. I've made an initial
|
||||
// guess at that.
|
||||
|
||||
if (update)
|
||||
{
|
||||
// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
|
||||
|
||||
AgentUpdateArgs arg = new AgentUpdateArgs();
|
||||
arg.AgentID = x.AgentID;
|
||||
arg.BodyRotation = x.BodyRotation;
|
||||
arg.CameraAtAxis = x.CameraAtAxis;
|
||||
arg.CameraCenter = x.CameraCenter;
|
||||
arg.CameraLeftAxis = x.CameraLeftAxis;
|
||||
arg.CameraUpAxis = x.CameraUpAxis;
|
||||
arg.ControlFlags = x.ControlFlags;
|
||||
arg.Far = x.Far;
|
||||
arg.Flags = x.Flags;
|
||||
arg.HeadRotation = x.HeadRotation;
|
||||
arg.SessionID = x.SessionID;
|
||||
arg.State = x.State;
|
||||
m_lastAgentUpdateArgs.AgentID = x.AgentID;
|
||||
m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation;
|
||||
m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
|
||||
m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter;
|
||||
m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
|
||||
m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
|
||||
m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags;
|
||||
m_lastAgentUpdateArgs.Far = x.Far;
|
||||
m_lastAgentUpdateArgs.Flags = x.Flags;
|
||||
m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation;
|
||||
m_lastAgentUpdateArgs.SessionID = x.SessionID;
|
||||
m_lastAgentUpdateArgs.State = x.State;
|
||||
|
||||
UpdateAgent handlerAgentUpdate = OnAgentUpdate;
|
||||
UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
|
||||
lastarg = arg; // save this set of arguments for nexttime
|
||||
|
||||
if (handlerPreAgentUpdate != null)
|
||||
OnPreAgentUpdate(this, arg);
|
||||
OnPreAgentUpdate(this, m_lastAgentUpdateArgs);
|
||||
|
||||
if (handlerAgentUpdate != null)
|
||||
OnAgentUpdate(this, arg);
|
||||
OnAgentUpdate(this, m_lastAgentUpdateArgs);
|
||||
|
||||
handlerAgentUpdate = null;
|
||||
handlerPreAgentUpdate = null;
|
||||
}
|
||||
}
|
||||
|
||||
PacketPool.Instance.ReturnPacket(packet);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5810,7 +5846,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
args.Channel = ch;
|
||||
args.From = String.Empty;
|
||||
args.Message = Utils.BytesToString(msg);
|
||||
args.Type = ChatTypeEnum.Shout;
|
||||
args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
|
||||
args.Position = new Vector3();
|
||||
args.Scene = Scene;
|
||||
args.Sender = this;
|
||||
@@ -9043,7 +9079,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
#endregion
|
||||
|
||||
switch (Utils.BytesToString(messagePacket.MethodData.Method))
|
||||
string method = Utils.BytesToString(messagePacket.MethodData.Method);
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "getinfo":
|
||||
if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
|
||||
@@ -9359,7 +9397,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
return true;
|
||||
|
||||
default:
|
||||
m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket);
|
||||
m_log.WarnFormat(
|
||||
"[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
|
||||
method, Name, Scene.Name);
|
||||
|
||||
for (int i = 0; i < messagePacket.ParamList.Length; i++)
|
||||
{
|
||||
EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
|
||||
string data = (string)Utils.BytesToString(block.Parameter);
|
||||
m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11745,7 +11793,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
logPacket = false;
|
||||
|
||||
if (DebugPacketLevel <= 50
|
||||
& (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
|
||||
&& (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
|
||||
logPacket = false;
|
||||
|
||||
if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
|
||||
@@ -11814,13 +11862,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
if (logPacket)
|
||||
m_log.DebugFormat(
|
||||
"[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
|
||||
Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
|
||||
Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
|
||||
}
|
||||
|
||||
if (!ProcessPacketMethod(packet))
|
||||
m_log.Warn("[CLIENT]: unhandled packet " + packet.Type);
|
||||
|
||||
PacketPool.Instance.ReturnPacket(packet);
|
||||
m_log.WarnFormat(
|
||||
"[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
|
||||
packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
|
||||
}
|
||||
|
||||
private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
|
||||
@@ -11989,7 +12037,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
Kick(reason);
|
||||
Thread.Sleep(1000);
|
||||
Close();
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
@@ -12273,7 +12321,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
|
||||
|
||||
|
||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
||||
ImprovedTerseObjectUpdatePacket packet
|
||||
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
|
||||
PacketType.ImprovedTerseObjectUpdate);
|
||||
|
||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||
packet.RegionData.TimeDilation = timeDilation;
|
||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public string GetStats()
|
||||
{
|
||||
return string.Format(
|
||||
"{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7} {12,7}",
|
||||
"{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}",
|
||||
Util.EnvironmentTickCountSubtract(TickLastPacketReceived),
|
||||
PacketsReceived,
|
||||
PacketsSent,
|
||||
@@ -290,8 +290,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.Cloud].Count,
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.Task].Count,
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.Texture].Count,
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.Asset].Count,
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.State].Count);
|
||||
m_packetOutboxes[(int)ThrottleOutPacketType.Asset].Count);
|
||||
}
|
||||
|
||||
public void SendPacketStats()
|
||||
@@ -337,8 +336,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
|
||||
int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
|
||||
int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
|
||||
// State is a subcategory of task that we allocate a percentage to
|
||||
int state = 0;
|
||||
|
||||
// Make sure none of the throttles are set below our packet MTU,
|
||||
// otherwise a throttle could become permanently clogged
|
||||
@@ -375,9 +372,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
bucket = m_throttleCategories[(int)ThrottleOutPacketType.Task];
|
||||
bucket.RequestedDripRate = task;
|
||||
|
||||
bucket = m_throttleCategories[(int)ThrottleOutPacketType.State];
|
||||
bucket.RequestedDripRate = state;
|
||||
|
||||
bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture];
|
||||
bucket.RequestedDripRate = texture;
|
||||
|
||||
@@ -678,9 +672,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Texture = 5,
|
||||
/// <summary>Non-texture assets</summary>
|
||||
Asset = 6,
|
||||
/// <summary>Avatar and primitive data</summary>
|
||||
/// <remarks>This is a sub-category of Task</remarks>
|
||||
State = 7,
|
||||
*/
|
||||
|
||||
switch (category)
|
||||
@@ -697,11 +688,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
return ThrottleOutPacketTypeFlags.Texture;
|
||||
case ThrottleOutPacketType.Asset:
|
||||
return ThrottleOutPacketTypeFlags.Asset;
|
||||
case ThrottleOutPacketType.State:
|
||||
return ThrottleOutPacketTypeFlags.State;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenMetaverse;
|
||||
@@ -69,6 +70,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public void AddScene(IScene scene)
|
||||
{
|
||||
m_udpServer.AddScene(scene);
|
||||
|
||||
StatsManager.RegisterStat(
|
||||
new Stat(
|
||||
"IncomingPacketsProcessedCount",
|
||||
"Number of inbound UDP packets processed",
|
||||
"Number of inbound UDP packets processed",
|
||||
"",
|
||||
"clientstack",
|
||||
scene.Name,
|
||||
StatType.Pull,
|
||||
MeasuresOfInterest.AverageChangeOverTime,
|
||||
stat => stat.Value = m_udpServer.IncomingPacketsProcessed,
|
||||
StatVerbosity.Debug));
|
||||
}
|
||||
|
||||
public bool HandlesRegion(Location x)
|
||||
@@ -100,9 +114,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
/// <summary>The measured resolution of Environment.TickCount</summary>
|
||||
public readonly float TickCountResolution;
|
||||
|
||||
/// <summary>Number of prim updates to put on the queue each time the
|
||||
/// OnQueueEmpty event is triggered for updates</summary>
|
||||
public readonly int PrimUpdatesPerCallback;
|
||||
|
||||
/// <summary>Number of texture packets to put on the queue each time the
|
||||
/// OnQueueEmpty event is triggered for textures</summary>
|
||||
public readonly int TextureSendLimit;
|
||||
@@ -111,6 +127,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
//PacketEventDictionary packetEvents = new PacketEventDictionary();
|
||||
/// <summary>Incoming packets that are awaiting handling</summary>
|
||||
private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>();
|
||||
|
||||
/// <summary></summary>
|
||||
//private UDPClientCollection m_clients = new UDPClientCollection();
|
||||
/// <summary>Bandwidth throttle for this UDP server</summary>
|
||||
@@ -121,28 +138,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
/// <summary>Manages authentication for agent circuits</summary>
|
||||
private AgentCircuitManager m_circuitManager;
|
||||
|
||||
/// <summary>Reference to the scene this UDP server is attached to</summary>
|
||||
protected Scene m_scene;
|
||||
|
||||
/// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary>
|
||||
private Location m_location;
|
||||
|
||||
/// <summary>The size of the receive buffer for the UDP socket. This value
|
||||
/// is passed up to the operating system and used in the system networking
|
||||
/// stack. Use zero to leave this value as the default</summary>
|
||||
private int m_recvBufferSize;
|
||||
|
||||
/// <summary>Flag to process packets asynchronously or synchronously</summary>
|
||||
private bool m_asyncPacketHandling;
|
||||
|
||||
/// <summary>Tracks whether or not a packet was sent each round so we know
|
||||
/// whether or not to sleep</summary>
|
||||
private bool m_packetSent;
|
||||
|
||||
/// <summary>Environment.TickCount of the last time that packet stats were reported to the scene</summary>
|
||||
private int m_elapsedMSSinceLastStatReport = 0;
|
||||
|
||||
/// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
|
||||
private int m_tickLastOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
|
||||
private int m_elapsedMSOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed</summary>
|
||||
private int m_elapsed100MSOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed</summary>
|
||||
private int m_elapsed500MSOutgoingPacketHandler;
|
||||
|
||||
@@ -155,6 +181,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// <summary>Flag to signal when clients should send pings</summary>
|
||||
protected bool m_sendPing;
|
||||
|
||||
private Pool<IncomingPacket> m_incomingPacketPool;
|
||||
|
||||
/// <summary>
|
||||
/// Stat for number of packets in the main pool awaiting use.
|
||||
/// </summary>
|
||||
private Stat m_poolCountStat;
|
||||
|
||||
/// <summary>
|
||||
/// Stat for number of packets in the inbound packet pool awaiting use.
|
||||
/// </summary>
|
||||
private Stat m_incomingPacketPoolStat;
|
||||
|
||||
private int m_defaultRTO = 0;
|
||||
private int m_maxRTO = 0;
|
||||
private int m_ackTimeout = 0;
|
||||
@@ -175,7 +213,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// </summary>
|
||||
private IClientAPI m_currentIncomingClient;
|
||||
|
||||
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
||||
public LLUDPServer(
|
||||
IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port,
|
||||
IConfigSource configSource, AgentCircuitManager circuitManager)
|
||||
: base(listenIP, (int)port)
|
||||
{
|
||||
#region Environment.TickCount Measurement
|
||||
@@ -197,6 +237,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
m_circuitManager = circuitManager;
|
||||
int sceneThrottleBps = 0;
|
||||
bool usePools = false;
|
||||
|
||||
IConfig config = configSource.Configs["ClientStack.LindenUDP"];
|
||||
if (config != null)
|
||||
@@ -222,6 +263,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_pausedAckTimeout = 1000 * 300; // 5 minutes
|
||||
}
|
||||
|
||||
// FIXME: This actually only needs to be done once since the PacketPool is shared across all servers.
|
||||
// However, there is no harm in temporarily doing it multiple times.
|
||||
IConfig packetConfig = configSource.Configs["PacketPool"];
|
||||
if (packetConfig != null)
|
||||
{
|
||||
PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
|
||||
PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
|
||||
usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools);
|
||||
}
|
||||
|
||||
#region BinaryStats
|
||||
config = configSource.Configs["Statistics.Binary"];
|
||||
m_shouldCollectStats = false;
|
||||
@@ -249,20 +300,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
m_throttle = new TokenBucket(null, sceneThrottleBps);
|
||||
ThrottleRates = new ThrottleRates(configSource);
|
||||
|
||||
if (usePools)
|
||||
EnablePools();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (m_scene == null)
|
||||
throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference");
|
||||
StartInbound();
|
||||
StartOutbound();
|
||||
|
||||
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
||||
}
|
||||
|
||||
private void StartInbound()
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLUDPSERVER]: Starting the LLUDP server in {0} mode",
|
||||
m_asyncPacketHandling ? "asynchronous" : "synchronous");
|
||||
"[LLUDPSERVER]: Starting inbound packet processing for the LLUDP server in {0} mode with UsePools = {1}",
|
||||
m_asyncPacketHandling ? "asynchronous" : "synchronous", UsePools);
|
||||
|
||||
base.Start(m_recvBufferSize, m_asyncPacketHandling);
|
||||
base.StartInbound(m_recvBufferSize, m_asyncPacketHandling);
|
||||
|
||||
// Start the packet processing threads
|
||||
// This thread will process the packets received that are placed on the packetInbox
|
||||
Watchdog.StartThread(
|
||||
IncomingPacketHandler,
|
||||
string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName),
|
||||
@@ -271,6 +330,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
true,
|
||||
GetWatchdogIncomingAlarmData,
|
||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
private new void StartOutbound()
|
||||
{
|
||||
m_log.Info("[LLUDPSERVER]: Starting outbound packet processing for the LLUDP server");
|
||||
|
||||
base.StartOutbound();
|
||||
|
||||
Watchdog.StartThread(
|
||||
OutgoingPacketHandler,
|
||||
@@ -280,8 +346,90 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
true,
|
||||
GetWatchdogOutgoingAlarmData,
|
||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
||||
public void Stop()
|
||||
{
|
||||
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
||||
base.StopOutbound();
|
||||
base.StopInbound();
|
||||
}
|
||||
|
||||
protected override bool EnablePools()
|
||||
{
|
||||
if (!UsePools)
|
||||
{
|
||||
base.EnablePools();
|
||||
|
||||
m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool DisablePools()
|
||||
{
|
||||
if (UsePools)
|
||||
{
|
||||
base.DisablePools();
|
||||
|
||||
StatsManager.DeregisterStat(m_incomingPacketPoolStat);
|
||||
|
||||
// We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a seperate method so that it can be called once we have an m_scene to distinguish different scene
|
||||
/// stats.
|
||||
/// </summary>
|
||||
private void EnablePoolStats()
|
||||
{
|
||||
m_poolCountStat
|
||||
= new Stat(
|
||||
"UDPPacketBufferPoolCount",
|
||||
"Objects within the UDPPacketBuffer pool",
|
||||
"The number of objects currently stored within the UDPPacketBuffer pool",
|
||||
"",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat => stat.Value = Pool.Count,
|
||||
StatVerbosity.Debug);
|
||||
|
||||
StatsManager.RegisterStat(m_poolCountStat);
|
||||
|
||||
m_incomingPacketPoolStat
|
||||
= new Stat(
|
||||
"IncomingPacketPoolCount",
|
||||
"Objects within incoming packet pool",
|
||||
"The number of objects currently stored within the incoming packet pool",
|
||||
"",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat => stat.Value = m_incomingPacketPool.Count,
|
||||
StatVerbosity.Debug);
|
||||
|
||||
StatsManager.RegisterStat(m_incomingPacketPoolStat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables pool stats.
|
||||
/// </summary>
|
||||
private void DisablePoolStats()
|
||||
{
|
||||
StatsManager.DeregisterStat(m_poolCountStat);
|
||||
m_poolCountStat = null;
|
||||
|
||||
StatsManager.DeregisterStat(m_incomingPacketPoolStat);
|
||||
m_incomingPacketPoolStat = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -306,12 +454,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none");
|
||||
}
|
||||
|
||||
public new void Stop()
|
||||
{
|
||||
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
||||
base.Stop();
|
||||
}
|
||||
|
||||
public void AddScene(IScene scene)
|
||||
{
|
||||
if (m_scene != null)
|
||||
@@ -328,6 +470,182 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
m_scene = (Scene)scene;
|
||||
m_location = new Location(m_scene.RegionInfo.RegionHandle);
|
||||
|
||||
// XXX: These stats are also pool stats but we register them separately since they are currently not
|
||||
// turned on and off by EnablePools()/DisablePools()
|
||||
StatsManager.RegisterStat(
|
||||
new PercentageStat(
|
||||
"PacketsReused",
|
||||
"Packets reused",
|
||||
"Number of packets reused out of all requests to the packet pool",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat =>
|
||||
{ PercentageStat pstat = (PercentageStat)stat;
|
||||
pstat.Consequent = PacketPool.Instance.PacketsRequested;
|
||||
pstat.Antecedent = PacketPool.Instance.PacketsReused; },
|
||||
StatVerbosity.Debug));
|
||||
|
||||
StatsManager.RegisterStat(
|
||||
new PercentageStat(
|
||||
"PacketDataBlocksReused",
|
||||
"Packet data blocks reused",
|
||||
"Number of data blocks reused out of all requests to the packet pool",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat =>
|
||||
{ PercentageStat pstat = (PercentageStat)stat;
|
||||
pstat.Consequent = PacketPool.Instance.BlocksRequested;
|
||||
pstat.Antecedent = PacketPool.Instance.BlocksReused; },
|
||||
StatVerbosity.Debug));
|
||||
|
||||
StatsManager.RegisterStat(
|
||||
new Stat(
|
||||
"PacketsPoolCount",
|
||||
"Objects within the packet pool",
|
||||
"The number of objects currently stored within the packet pool",
|
||||
"",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat => stat.Value = PacketPool.Instance.PacketsPooled,
|
||||
StatVerbosity.Debug));
|
||||
|
||||
StatsManager.RegisterStat(
|
||||
new Stat(
|
||||
"PacketDataBlocksPoolCount",
|
||||
"Objects within the packet data block pool",
|
||||
"The number of objects currently stored within the packet data block pool",
|
||||
"",
|
||||
"clientstack",
|
||||
m_scene.Name,
|
||||
StatType.Pull,
|
||||
stat => stat.Value = PacketPool.Instance.BlocksPooled,
|
||||
StatVerbosity.Debug));
|
||||
|
||||
// We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by
|
||||
// scene name
|
||||
if (UsePools)
|
||||
EnablePoolStats();
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Debug",
|
||||
false,
|
||||
"debug lludp start",
|
||||
"debug lludp start <in|out|all>",
|
||||
"Control LLUDP packet processing.",
|
||||
"No effect if packet processing has already started.\n"
|
||||
+ "in - start inbound processing.\n"
|
||||
+ "out - start outbound processing.\n"
|
||||
+ "all - start in and outbound processing.\n",
|
||||
HandleStartCommand);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Debug",
|
||||
false,
|
||||
"debug lludp stop",
|
||||
"debug lludp stop <in|out|all>",
|
||||
"Stop LLUDP packet processing.",
|
||||
"No effect if packet processing has already stopped.\n"
|
||||
+ "in - stop inbound processing.\n"
|
||||
+ "out - stop outbound processing.\n"
|
||||
+ "all - stop in and outbound processing.\n",
|
||||
HandleStopCommand);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Debug",
|
||||
false,
|
||||
"debug lludp pool",
|
||||
"debug lludp pool <on|off>",
|
||||
"Turn object pooling within the lludp component on or off.",
|
||||
HandlePoolCommand);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Debug",
|
||||
false,
|
||||
"debug lludp status",
|
||||
"debug lludp status",
|
||||
"Return status of LLUDP packet processing.",
|
||||
HandleStatusCommand);
|
||||
}
|
||||
|
||||
private void HandleStartCommand(string module, string[] args)
|
||||
{
|
||||
if (args.Length != 4)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
|
||||
return;
|
||||
}
|
||||
|
||||
string subCommand = args[3];
|
||||
|
||||
if (subCommand == "in" || subCommand == "all")
|
||||
StartInbound();
|
||||
|
||||
if (subCommand == "out" || subCommand == "all")
|
||||
StartOutbound();
|
||||
}
|
||||
|
||||
private void HandleStopCommand(string module, string[] args)
|
||||
{
|
||||
if (args.Length != 4)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
|
||||
return;
|
||||
}
|
||||
|
||||
string subCommand = args[3];
|
||||
|
||||
if (subCommand == "in" || subCommand == "all")
|
||||
StopInbound();
|
||||
|
||||
if (subCommand == "out" || subCommand == "all")
|
||||
StopOutbound();
|
||||
}
|
||||
|
||||
private void HandlePoolCommand(string module, string[] args)
|
||||
{
|
||||
if (args.Length != 4)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
|
||||
return;
|
||||
}
|
||||
|
||||
string enabled = args[3];
|
||||
|
||||
if (enabled == "on")
|
||||
{
|
||||
if (EnablePools())
|
||||
{
|
||||
EnablePoolStats();
|
||||
MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name);
|
||||
}
|
||||
}
|
||||
else if (enabled == "off")
|
||||
{
|
||||
if (DisablePools())
|
||||
{
|
||||
DisablePoolStats();
|
||||
MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleStatusCommand(string module, string[] args)
|
||||
{
|
||||
MainConsole.Instance.OutputFormat(
|
||||
"IN LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningInbound ? "enabled" : "disabled");
|
||||
|
||||
MainConsole.Instance.OutputFormat(
|
||||
"OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
|
||||
|
||||
MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off");
|
||||
}
|
||||
|
||||
public bool HandlesRegion(Location x)
|
||||
@@ -411,6 +729,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
byte[] data = packet.ToBytes();
|
||||
SendPacketData(udpClient, data, packet.Type, category, method);
|
||||
}
|
||||
|
||||
PacketPool.Instance.ReturnPacket(packet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -695,7 +1015,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
LLUDPClient udpClient = null;
|
||||
Packet packet = null;
|
||||
int packetEnd = buffer.DataLength - 1;
|
||||
IPEndPoint address = (IPEndPoint)buffer.RemoteEndPoint;
|
||||
IPEndPoint endPoint = (IPEndPoint)buffer.RemoteEndPoint;
|
||||
|
||||
#region Decoding
|
||||
|
||||
@@ -705,7 +1025,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// "[LLUDPSERVER]: Dropping undersized packet with {0} bytes received from {1} in {2}",
|
||||
// buffer.DataLength, buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
|
||||
|
||||
return; // Drop undersizd packet
|
||||
return; // Drop undersized packet
|
||||
}
|
||||
|
||||
int headerLen = 7;
|
||||
@@ -728,7 +1048,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
try
|
||||
{
|
||||
packet = Packet.BuildPacket(buffer.Data, ref packetEnd,
|
||||
// packet = Packet.BuildPacket(buffer.Data, ref packetEnd,
|
||||
// // Only allocate a buffer for zerodecoding if the packet is zerocoded
|
||||
// ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null);
|
||||
// If OpenSimUDPBase.UsePool == true (which is currently separate from the PacketPool) then we
|
||||
// assume that packet construction does not retain a reference to byte[] buffer.Data (instead, all
|
||||
// bytes are copied out).
|
||||
packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd,
|
||||
// Only allocate a buffer for zerodecoding if the packet is zerocoded
|
||||
((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null);
|
||||
}
|
||||
@@ -743,11 +1069,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
return; // Drop short packet
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_malformedCount < 100)
|
||||
m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString());
|
||||
|
||||
m_malformedCount++;
|
||||
|
||||
if ((m_malformedCount % 100000) == 0)
|
||||
m_log.DebugFormat("[LLUDPSERVER]: Received {0} malformed packets so far, probable network attack.", m_malformedCount);
|
||||
}
|
||||
@@ -768,7 +1096,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// UseCircuitCode handling
|
||||
if (packet.Type == PacketType.UseCircuitCode)
|
||||
{
|
||||
object[] array = new object[] { buffer, packet };
|
||||
// We need to copy the endpoint so that it doesn't get changed when another thread reuses the
|
||||
// buffer.
|
||||
object[] array = new object[] { new IPEndPoint(endPoint.Address, endPoint.Port), packet };
|
||||
|
||||
Util.FireAndForget(HandleUseCircuitCode, array);
|
||||
|
||||
@@ -777,7 +1107,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
// Determine which agent this packet came from
|
||||
IClientAPI client;
|
||||
if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
|
||||
if (!m_scene.TryGetClient(endPoint, out client) || !(client is LLClientView))
|
||||
{
|
||||
//m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
|
||||
return;
|
||||
@@ -801,6 +1131,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// Handle appended ACKs
|
||||
if (packet.Header.AppendedAcks && packet.Header.AckList != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LLUDPSERVER]: Handling {0} appended acks from {1} in {2}",
|
||||
// packet.Header.AckList.Length, client.Name, m_scene.Name);
|
||||
|
||||
for (int i = 0; i < packet.Header.AckList.Length; i++)
|
||||
udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent);
|
||||
}
|
||||
@@ -810,6 +1144,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
PacketAckPacket ackPacket = (PacketAckPacket)packet;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[LLUDPSERVER]: Handling {0} packet acks for {1} in {2}",
|
||||
// ackPacket.Packets.Length, client.Name, m_scene.Name);
|
||||
|
||||
for (int i = 0; i < ackPacket.Packets.Length; i++)
|
||||
udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent);
|
||||
|
||||
@@ -823,6 +1161,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
if (packet.Header.Reliable)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LLUDPSERVER]: Adding ack request for {0} {1} from {2} in {3}",
|
||||
// packet.Type, packet.Header.Sequence, client.Name, m_scene.Name);
|
||||
|
||||
udpClient.PendingAcks.Enqueue(packet.Header.Sequence);
|
||||
|
||||
// This is a somewhat odd sequence of steps to pull the client.BytesSinceLastACK value out,
|
||||
@@ -869,6 +1211,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
if (packet.Type == PacketType.StartPingCheck)
|
||||
{
|
||||
// m_log.DebugFormat("[LLUDPSERVER]: Handling ping from {0} in {1}", client.Name, m_scene.Name);
|
||||
|
||||
// We don't need to do anything else with ping checks
|
||||
StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
|
||||
CompletePing(udpClient, startPing.PingID.PingID);
|
||||
@@ -888,8 +1232,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
#endregion Ping Check Handling
|
||||
|
||||
IncomingPacket incomingPacket;
|
||||
|
||||
// Inbox insertion
|
||||
packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet));
|
||||
if (UsePools)
|
||||
{
|
||||
incomingPacket = m_incomingPacketPool.GetObject();
|
||||
incomingPacket.Client = (LLClientView)client;
|
||||
incomingPacket.Packet = packet;
|
||||
}
|
||||
else
|
||||
{
|
||||
incomingPacket = new IncomingPacket((LLClientView)client, packet);
|
||||
}
|
||||
|
||||
packetInbox.Enqueue(incomingPacket);
|
||||
}
|
||||
|
||||
#region BinaryStats
|
||||
@@ -975,21 +1332,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
private void HandleUseCircuitCode(object o)
|
||||
{
|
||||
IPEndPoint remoteEndPoint = null;
|
||||
IPEndPoint endPoint = null;
|
||||
IClientAPI client = null;
|
||||
|
||||
try
|
||||
{
|
||||
// DateTime startTime = DateTime.Now;
|
||||
object[] array = (object[])o;
|
||||
UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
|
||||
endPoint = (IPEndPoint)array[0];
|
||||
UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} to {1} from IP {2}",
|
||||
uccp.CircuitCode.Code, m_scene.RegionInfo.RegionName, buffer.RemoteEndPoint);
|
||||
|
||||
remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
|
||||
uccp.CircuitCode.Code, m_scene.RegionInfo.RegionName, endPoint);
|
||||
|
||||
AuthenticateResponse sessionInfo;
|
||||
if (IsClientAuthorized(uccp, out sessionInfo))
|
||||
@@ -1000,13 +1355,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
uccp.CircuitCode.Code,
|
||||
uccp.CircuitCode.ID,
|
||||
uccp.CircuitCode.SessionID,
|
||||
remoteEndPoint,
|
||||
endPoint,
|
||||
sessionInfo);
|
||||
|
||||
// Send ack straight away to let the viewer know that the connection is active.
|
||||
// The client will be null if it already exists (e.g. if on a region crossing the client sends a use
|
||||
// circuit code to the existing child agent. This is not particularly obvious.
|
||||
SendAckImmediate(remoteEndPoint, uccp.Header.Sequence);
|
||||
SendAckImmediate(endPoint, uccp.Header.Sequence);
|
||||
|
||||
// We only want to send initial data to new clients, not ones which are being converted from child to root.
|
||||
if (client != null)
|
||||
@@ -1017,7 +1372,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// Don't create clients for unauthorized requesters.
|
||||
m_log.WarnFormat(
|
||||
"[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}",
|
||||
uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, remoteEndPoint);
|
||||
uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint);
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
@@ -1029,7 +1384,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[LLUDPSERVER]: UseCircuitCode handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}",
|
||||
remoteEndPoint != null ? remoteEndPoint.ToString() : "n/a",
|
||||
endPoint != null ? endPoint.ToString() : "n/a",
|
||||
client != null ? client.Name : "unknown",
|
||||
client != null ? client.AgentId.ToString() : "unknown",
|
||||
e.Message,
|
||||
@@ -1094,20 +1449,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
IClientAPI client = null;
|
||||
|
||||
// In priciple there shouldn't be more than one thread here, ever.
|
||||
// But in case that happens, we need to synchronize this piece of code
|
||||
// because it's too important
|
||||
lock (this)
|
||||
// We currently synchronize this code across the whole scene to avoid issues such as
|
||||
// http://opensimulator.org/mantis/view.php?id=5365 However, once locking per agent circuit can be done
|
||||
// consistently, this lock could probably be removed.
|
||||
lock (this)
|
||||
{
|
||||
if (!m_scene.TryGetClient(agentID, out client))
|
||||
{
|
||||
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
|
||||
|
||||
|
||||
client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
|
||||
client.OnLogout += LogoutHandler;
|
||||
|
||||
|
||||
((LLClientView)client).DisableFacelights = m_disableFacelights;
|
||||
|
||||
|
||||
client.Start();
|
||||
}
|
||||
}
|
||||
@@ -1146,7 +1501,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// on to en-US to avoid number parsing issues
|
||||
Culture.SetCurrentCulture();
|
||||
|
||||
while (base.IsRunning)
|
||||
while (IsRunningInbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1161,7 +1516,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
|
||||
if (packetInbox.Dequeue(100, ref incomingPacket))
|
||||
{
|
||||
ProcessInPacket(incomingPacket);//, incomingPacket); Util.FireAndForget(ProcessInPacket, incomingPacket);
|
||||
|
||||
if (UsePools)
|
||||
m_incomingPacketPool.ReturnObject(incomingPacket);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1188,7 +1548,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// Action generic every round
|
||||
Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
|
||||
|
||||
while (base.IsRunning)
|
||||
while (base.IsRunningOutbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1315,6 +1675,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
private int npacksSent = 0;
|
||||
private int npackNotSent = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Number of inbound packets processed since startup.
|
||||
/// </summary>
|
||||
public long IncomingPacketsProcessed { get; private set; }
|
||||
|
||||
private void MonitoredClientOutgoingPacketHandler(IClientAPI client)
|
||||
{
|
||||
nticks++;
|
||||
@@ -1374,7 +1739,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
npacksSent++;
|
||||
}
|
||||
else
|
||||
{
|
||||
npackNotSent++;
|
||||
}
|
||||
|
||||
watch2.Stop();
|
||||
avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
|
||||
@@ -1382,7 +1749,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1446,6 +1815,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
"[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
|
||||
packet.Type, client.Name, m_scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
IncomingPacketsProcessed++;
|
||||
}
|
||||
|
||||
protected void LogoutHandler(IClientAPI client)
|
||||
|
||||
@@ -30,6 +30,8 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenMetaverse
|
||||
{
|
||||
@@ -58,17 +60,29 @@ namespace OpenMetaverse
|
||||
/// <summary>Flag to process packets asynchronously or synchronously</summary>
|
||||
private bool m_asyncPacketHandling;
|
||||
|
||||
/// <summary>The all important shutdown flag</summary>
|
||||
private volatile bool m_shutdownFlag = true;
|
||||
/// <summary>
|
||||
/// Are we to use object pool(s) to reduce memory churn when receiving data?
|
||||
/// </summary>
|
||||
public bool UsePools { get; protected set; }
|
||||
|
||||
/// <summary>Returns true if the server is currently listening, otherwise false</summary>
|
||||
public bool IsRunning { get { return !m_shutdownFlag; } }
|
||||
/// <summary>
|
||||
/// Pool to use for handling data. May be null if UsePools = false;
|
||||
/// </summary>
|
||||
protected OpenSim.Framework.Pool<UDPPacketBuffer> Pool { get; private set; }
|
||||
|
||||
/// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary>
|
||||
public bool IsRunningInbound { get; private set; }
|
||||
|
||||
/// <summary>Returns true if the server is currently sending outbound packets, otherwise false</summary>
|
||||
/// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks>
|
||||
public bool IsRunningOutbound { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
/// <param name="bindAddress">Local IP address to bind the server to</param>
|
||||
/// <param name="port">Port to listening for incoming UDP packets on</param>
|
||||
/// /// <param name="usePool">Are we to use an object pool to get objects for handing inbound data?</param>
|
||||
public OpenSimUDPBase(IPAddress bindAddress, int port)
|
||||
{
|
||||
m_localBindAddress = bindAddress;
|
||||
@@ -76,7 +90,7 @@ namespace OpenMetaverse
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start the UDP server
|
||||
/// Start inbound UDP packet handling.
|
||||
/// </summary>
|
||||
/// <param name="recvBufferSize">The size of the receive buffer for
|
||||
/// the UDP socket. This value is passed up to the operating system
|
||||
@@ -91,11 +105,11 @@ namespace OpenMetaverse
|
||||
/// manner (not throwing an exception when the remote side resets the
|
||||
/// connection). This call is ignored on Mono where the flag is not
|
||||
/// necessary</remarks>
|
||||
public void Start(int recvBufferSize, bool asyncPacketHandling)
|
||||
public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
|
||||
{
|
||||
m_asyncPacketHandling = asyncPacketHandling;
|
||||
|
||||
if (m_shutdownFlag)
|
||||
if (!IsRunningInbound)
|
||||
{
|
||||
const int SIO_UDP_CONNRESET = -1744830452;
|
||||
|
||||
@@ -127,8 +141,7 @@ namespace OpenMetaverse
|
||||
|
||||
m_udpSocket.Bind(ipep);
|
||||
|
||||
// we're not shutting down, we're starting up
|
||||
m_shutdownFlag = false;
|
||||
IsRunningInbound = true;
|
||||
|
||||
// kick off an async receive. The Start() method will return, the
|
||||
// actual receives will occur asynchronously and will be caught in
|
||||
@@ -138,28 +151,69 @@ namespace OpenMetaverse
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the UDP server
|
||||
/// Start outbound UDP packet handling.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
public void StartOutbound()
|
||||
{
|
||||
if (!m_shutdownFlag)
|
||||
IsRunningOutbound = true;
|
||||
}
|
||||
|
||||
public void StopInbound()
|
||||
{
|
||||
if (IsRunningInbound)
|
||||
{
|
||||
// wait indefinitely for a writer lock. Once this is called, the .NET runtime
|
||||
// will deny any more reader locks, in effect blocking all other send/receive
|
||||
// threads. Once we have the lock, we set shutdownFlag to inform the other
|
||||
// threads. Once we have the lock, we set IsRunningInbound = false to inform the other
|
||||
// threads that the socket is closed.
|
||||
m_shutdownFlag = true;
|
||||
IsRunningInbound = false;
|
||||
m_udpSocket.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void StopOutbound()
|
||||
{
|
||||
IsRunningOutbound = false;
|
||||
}
|
||||
|
||||
protected virtual bool EnablePools()
|
||||
{
|
||||
if (!UsePools)
|
||||
{
|
||||
Pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
|
||||
|
||||
UsePools = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool DisablePools()
|
||||
{
|
||||
if (UsePools)
|
||||
{
|
||||
UsePools = false;
|
||||
|
||||
// We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AsyncBeginReceive()
|
||||
{
|
||||
// allocate a packet buffer
|
||||
//WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut();
|
||||
UDPPacketBuffer buf = new UDPPacketBuffer();
|
||||
UDPPacketBuffer buf;
|
||||
|
||||
if (!m_shutdownFlag)
|
||||
if (UsePools)
|
||||
buf = Pool.GetObject();
|
||||
else
|
||||
buf = new UDPPacketBuffer();
|
||||
|
||||
if (IsRunningInbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -212,7 +266,7 @@ namespace OpenMetaverse
|
||||
{
|
||||
// Asynchronous receive operations will complete here through the call
|
||||
// to AsyncBeginReceive
|
||||
if (!m_shutdownFlag)
|
||||
if (IsRunningInbound)
|
||||
{
|
||||
// Asynchronous mode will start another receive before the
|
||||
// callback for this packet is even fired. Very parallel :-)
|
||||
@@ -221,8 +275,6 @@ namespace OpenMetaverse
|
||||
|
||||
// get the buffer that was created in AsyncBeginReceive
|
||||
// this is the received data
|
||||
//WrappedObject<UDPPacketBuffer> wrappedBuffer = (WrappedObject<UDPPacketBuffer>)iar.AsyncState;
|
||||
//UDPPacketBuffer buffer = wrappedBuffer.Instance;
|
||||
UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState;
|
||||
|
||||
try
|
||||
@@ -239,7 +291,8 @@ namespace OpenMetaverse
|
||||
catch (ObjectDisposedException) { }
|
||||
finally
|
||||
{
|
||||
//wrappedBuffer.Dispose();
|
||||
if (UsePools)
|
||||
Pool.ReturnObject(buffer);
|
||||
|
||||
// Synchronous mode waits until the packet callback completes
|
||||
// before starting the receive to fetch another packet
|
||||
@@ -252,7 +305,7 @@ namespace OpenMetaverse
|
||||
|
||||
public void AsyncBeginSend(UDPPacketBuffer buf)
|
||||
{
|
||||
if (!m_shutdownFlag)
|
||||
if (IsRunningOutbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -281,4 +334,4 @@ namespace OpenMetaverse
|
||||
catch (ObjectDisposedException) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,63 +31,114 @@ using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using log4net;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
|
||||
public sealed class PacketPool
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static readonly PacketPool instance = new PacketPool();
|
||||
|
||||
private bool packetPoolEnabled = true;
|
||||
private bool dataBlockPoolEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// Pool of packets available for reuse.
|
||||
/// </summary>
|
||||
private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>();
|
||||
|
||||
private static Dictionary<Type, Stack<Object>> DataBlocks =
|
||||
new Dictionary<Type, Stack<Object>>();
|
||||
|
||||
static PacketPool()
|
||||
{
|
||||
}
|
||||
private static Dictionary<Type, Stack<Object>> DataBlocks = new Dictionary<Type, Stack<Object>>();
|
||||
|
||||
public static PacketPool Instance
|
||||
{
|
||||
get { return instance; }
|
||||
}
|
||||
|
||||
public bool RecyclePackets
|
||||
public bool RecyclePackets { get; set; }
|
||||
|
||||
public bool RecycleDataBlocks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of packets pooled
|
||||
/// </summary>
|
||||
public int PacketsPooled
|
||||
{
|
||||
set { packetPoolEnabled = value; }
|
||||
get { return packetPoolEnabled; }
|
||||
get
|
||||
{
|
||||
lock (pool)
|
||||
return pool.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RecycleDataBlocks
|
||||
/// <summary>
|
||||
/// The number of blocks pooled.
|
||||
/// </summary>
|
||||
public int BlocksPooled
|
||||
{
|
||||
set { dataBlockPoolEnabled = value; }
|
||||
get { return dataBlockPoolEnabled; }
|
||||
get
|
||||
{
|
||||
lock (DataBlocks)
|
||||
return DataBlocks.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of packets requested.
|
||||
/// </summary>
|
||||
public long PacketsRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packets reused.
|
||||
/// </summary>
|
||||
public long PacketsReused { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packet blocks requested.
|
||||
/// </summary>
|
||||
public long BlocksRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packet blocks reused.
|
||||
/// </summary>
|
||||
public long BlocksReused { get; private set; }
|
||||
|
||||
private PacketPool()
|
||||
{
|
||||
// defaults
|
||||
RecyclePackets = true;
|
||||
RecycleDataBlocks = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a packet of the given type.
|
||||
/// </summary>
|
||||
/// <param name='type'></param>
|
||||
/// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns>
|
||||
public Packet GetPacket(PacketType type)
|
||||
{
|
||||
PacketsRequested++;
|
||||
|
||||
Packet packet;
|
||||
|
||||
if (!packetPoolEnabled)
|
||||
if (!RecyclePackets)
|
||||
return Packet.BuildPacket(type);
|
||||
|
||||
lock (pool)
|
||||
{
|
||||
if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0)
|
||||
{
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
|
||||
|
||||
// Creating a new packet if we cannot reuse an old package
|
||||
packet = Packet.BuildPacket(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
|
||||
|
||||
// Recycle old packages
|
||||
packet = (pool[type]).Pop();
|
||||
PacketsReused++;
|
||||
|
||||
packet = pool[type].Pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +187,7 @@ namespace OpenSim.Framework
|
||||
{
|
||||
PacketType type = GetType(bytes);
|
||||
|
||||
Array.Clear(zeroBuffer, 0, zeroBuffer.Length);
|
||||
// Array.Clear(zeroBuffer, 0, zeroBuffer.Length);
|
||||
|
||||
int i = 0;
|
||||
Packet packet = GetPacket(type);
|
||||
@@ -154,7 +205,7 @@ namespace OpenSim.Framework
|
||||
/// <param name="packet"></param>
|
||||
public void ReturnPacket(Packet packet)
|
||||
{
|
||||
if (dataBlockPoolEnabled)
|
||||
if (RecycleDataBlocks)
|
||||
{
|
||||
switch (packet.Type)
|
||||
{
|
||||
@@ -178,11 +229,12 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
if (packetPoolEnabled)
|
||||
if (RecyclePackets)
|
||||
{
|
||||
switch (packet.Type)
|
||||
{
|
||||
// List pooling packets here
|
||||
case PacketType.AgentUpdate:
|
||||
case PacketType.PacketAck:
|
||||
case PacketType.ObjectUpdate:
|
||||
case PacketType.ImprovedTerseObjectUpdate:
|
||||
@@ -197,7 +249,9 @@ namespace OpenSim.Framework
|
||||
|
||||
if ((pool[type]).Count < 50)
|
||||
{
|
||||
(pool[type]).Push(packet);
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
|
||||
|
||||
pool[type].Push(packet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -209,16 +263,21 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetDataBlock<T>() where T: new()
|
||||
public T GetDataBlock<T>() where T: new()
|
||||
{
|
||||
lock (DataBlocks)
|
||||
{
|
||||
BlocksRequested++;
|
||||
|
||||
Stack<Object> s;
|
||||
|
||||
if (DataBlocks.TryGetValue(typeof(T), out s))
|
||||
{
|
||||
if (s.Count > 0)
|
||||
{
|
||||
BlocksReused++;
|
||||
return (T)s.Pop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,7 +288,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReturnDataBlock<T>(T block) where T: new()
|
||||
public void ReturnDataBlock<T>(T block) where T: new()
|
||||
{
|
||||
if (block == null)
|
||||
return;
|
||||
@@ -244,4 +303,4 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// This will contain basic tests for the LindenUDP client stack
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class BasicCircuitTests
|
||||
public class BasicCircuitTests : OpenSimTestCase
|
||||
{
|
||||
private Scene m_scene;
|
||||
private TestLLUDPServer m_udpServer;
|
||||
@@ -65,8 +65,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
m_scene = new SceneHelpers().SetupScene();
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
public void TestAddClient()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// XmlConfigurator.Configure();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
AddUdpServer();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common.Mock;
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LLImageManagerTests
|
||||
public class LLImageManagerTests : OpenSimTestCase
|
||||
{
|
||||
private AssetBase m_testImageAsset;
|
||||
private Scene scene;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// Tests for the LL packet handler
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class PacketHandlerTests
|
||||
public class PacketHandlerTests : OpenSimTestCase
|
||||
{
|
||||
// [Test]
|
||||
// /// <summary>
|
||||
|
||||
@@ -57,39 +57,36 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a xfer uploader if one does not already exist.
|
||||
/// Return the xfer uploader for the given transaction.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If an uploader does not already exist for this transaction then it is created, otherwise the existing
|
||||
/// uploader is returned.
|
||||
/// </remarks>
|
||||
/// <param name="transactionID"></param>
|
||||
/// <param name="assetID">
|
||||
/// We must transfer the new asset ID into the uploader on creation, otherwise
|
||||
/// we can see race conditions with other threads which can retrieve an item before it is updated with the new
|
||||
/// asset id.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The xfer uploader requested. Null if one is already in existence.
|
||||
/// FIXME: This is a bizarre thing to do, and is probably meant to signal an error condition if multiple
|
||||
/// transfers are made. Needs to be corrected.
|
||||
/// </returns>
|
||||
public AssetXferUploader RequestXferUploader(UUID transactionID, UUID assetID)
|
||||
/// <returns>The asset xfer uploader</returns>
|
||||
public AssetXferUploader RequestXferUploader(UUID transactionID)
|
||||
{
|
||||
AssetXferUploader uploader;
|
||||
|
||||
lock (XferUploaders)
|
||||
{
|
||||
if (!XferUploaders.ContainsKey(transactionID))
|
||||
{
|
||||
AssetXferUploader uploader = new AssetXferUploader(this, m_Scene, assetID, m_dumpAssetsToFile);
|
||||
uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID);
|
||||
|
||||
XferUploaders.Add(transactionID, uploader);
|
||||
|
||||
return uploader;
|
||||
}
|
||||
else
|
||||
{
|
||||
uploader = XferUploaders[transactionID];
|
||||
}
|
||||
}
|
||||
|
||||
m_log.WarnFormat("[AGENT ASSETS TRANSACTIONS]: Ignoring request for asset xfer uploader {0} since it already exists", transactionID);
|
||||
|
||||
return null;
|
||||
return uploader;
|
||||
}
|
||||
|
||||
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
|
||||
@@ -151,115 +148,28 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
string description, string name, sbyte invType,
|
||||
sbyte type, byte wearableType, uint nextOwnerMask)
|
||||
{
|
||||
AssetXferUploader uploader = null;
|
||||
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
||||
|
||||
lock (XferUploaders)
|
||||
{
|
||||
if (XferUploaders.ContainsKey(transactionID))
|
||||
uploader = XferUploaders[transactionID];
|
||||
}
|
||||
|
||||
if (uploader != null)
|
||||
uploader.RequestCreateInventoryItem(
|
||||
remoteClient, transactionID, folderID,
|
||||
callbackID, description, name, invType, type,
|
||||
wearableType, nextOwnerMask);
|
||||
else
|
||||
m_log.ErrorFormat(
|
||||
"[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to create inventory item {1} from {2}",
|
||||
transactionID, name, remoteClient.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an uploaded asset. If the data is successfully retrieved,
|
||||
/// the transaction will be removed.
|
||||
/// </summary>
|
||||
/// <param name="transactionID"></param>
|
||||
/// <returns>The asset if the upload has completed, null if it has not.</returns>
|
||||
private AssetBase GetTransactionAsset(UUID transactionID)
|
||||
{
|
||||
lock (XferUploaders)
|
||||
{
|
||||
if (XferUploaders.ContainsKey(transactionID))
|
||||
{
|
||||
AssetXferUploader uploader = XferUploaders[transactionID];
|
||||
AssetBase asset = uploader.GetAssetData();
|
||||
RemoveXferUploader(transactionID);
|
||||
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
uploader.RequestCreateInventoryItem(
|
||||
remoteClient, folderID, callbackID,
|
||||
description, name, invType, type, wearableType, nextOwnerMask);
|
||||
}
|
||||
|
||||
public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient,
|
||||
SceneObjectPart part, UUID transactionID,
|
||||
TaskInventoryItem item)
|
||||
{
|
||||
AssetXferUploader uploader = null;
|
||||
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
||||
|
||||
lock (XferUploaders)
|
||||
{
|
||||
if (XferUploaders.ContainsKey(transactionID))
|
||||
uploader = XferUploaders[transactionID];
|
||||
}
|
||||
|
||||
if (uploader != null)
|
||||
{
|
||||
AssetBase asset = GetTransactionAsset(transactionID);
|
||||
|
||||
// Only legacy viewers use this, and they prefer CAPS, which
|
||||
// we have, so this really never runs.
|
||||
// Allow it, but only for "safe" types.
|
||||
if ((InventoryType)item.InvType != InventoryType.Notecard &&
|
||||
(InventoryType)item.InvType != InventoryType.LSL)
|
||||
return;
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}",
|
||||
// item.Name, part.Name, transactionID);
|
||||
|
||||
asset.FullID = UUID.Random();
|
||||
asset.Name = item.Name;
|
||||
asset.Description = item.Description;
|
||||
asset.Type = (sbyte)item.Type;
|
||||
item.AssetID = asset.FullID;
|
||||
|
||||
m_Scene.AssetService.Store(asset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update task inventory item {1} in {2}",
|
||||
transactionID, item.Name, part.Name);
|
||||
}
|
||||
uploader.RequestUpdateTaskInventoryItem(remoteClient, item);
|
||||
}
|
||||
|
||||
public void RequestUpdateInventoryItem(IClientAPI remoteClient,
|
||||
UUID transactionID, InventoryItemBase item)
|
||||
{
|
||||
AssetXferUploader uploader = null;
|
||||
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
||||
|
||||
lock (XferUploaders)
|
||||
{
|
||||
if (XferUploaders.ContainsKey(transactionID))
|
||||
uploader = XferUploaders[transactionID];
|
||||
}
|
||||
|
||||
if (uploader != null)
|
||||
{
|
||||
uploader.RequestUpdateInventoryItem(remoteClient, transactionID, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update inventory item {1} for {2}",
|
||||
transactionID, item.Name, remoteClient.Name);
|
||||
}
|
||||
uploader.RequestUpdateInventoryItem(remoteClient, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
|
||||
"[ASSET TRANSACTION MODULE] Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
|
||||
item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);
|
||||
|
||||
AgentAssetTransactions transactions =
|
||||
@@ -274,13 +274,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
}
|
||||
|
||||
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||
AssetXferUploader uploader = transactions.RequestXferUploader(transaction, assetID);
|
||||
|
||||
if (uploader != null)
|
||||
{
|
||||
uploader.Initialise(remoteClient, assetID, transaction, type,
|
||||
data, storeLocal, tempFile);
|
||||
}
|
||||
AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
|
||||
uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -40,39 +40,75 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Upload state.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// New -> Uploading -> Complete
|
||||
/// </remarks>
|
||||
private enum UploadState
|
||||
{
|
||||
New,
|
||||
Uploading,
|
||||
Complete
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we
|
||||
/// are performing a delayed update.
|
||||
/// </summary>
|
||||
AgentAssetTransactions m_transactions;
|
||||
|
||||
private UploadState m_uploadState = UploadState.New;
|
||||
|
||||
private AssetBase m_asset;
|
||||
private UUID InventFolder = UUID.Zero;
|
||||
private sbyte invType = 0;
|
||||
|
||||
private bool m_createItem = false;
|
||||
private uint m_createItemCallback = 0;
|
||||
private bool m_updateItem = false;
|
||||
private bool m_createItem;
|
||||
private uint m_createItemCallback;
|
||||
|
||||
private bool m_updateItem;
|
||||
private InventoryItemBase m_updateItemData;
|
||||
|
||||
private bool m_updateTaskItem;
|
||||
private TaskInventoryItem m_updateTaskItemData;
|
||||
|
||||
private string m_description = String.Empty;
|
||||
private bool m_dumpAssetToFile;
|
||||
private bool m_finished = false;
|
||||
private string m_name = String.Empty;
|
||||
private bool m_storeLocal;
|
||||
// private bool m_storeLocal;
|
||||
private uint nextPerm = 0;
|
||||
private IClientAPI ourClient;
|
||||
private UUID TransactionID = UUID.Zero;
|
||||
|
||||
private UUID m_transactionID;
|
||||
|
||||
private sbyte type = 0;
|
||||
private byte wearableType = 0;
|
||||
public ulong XferID;
|
||||
private Scene m_Scene;
|
||||
|
||||
public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile)
|
||||
/// <summary>
|
||||
/// AssetXferUploader constructor
|
||||
/// </summary>
|
||||
/// <param name='transactions'>/param>
|
||||
/// <param name='scene'></param>
|
||||
/// <param name='transactionID'></param>
|
||||
/// <param name='dumpAssetToFile'>
|
||||
/// If true then when the asset is uploaded it is dumped to a file with the format
|
||||
/// String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
|
||||
/// now.Year, now.Month, now.Day, now.Hour, now.Minute,
|
||||
/// now.Second, m_asset.Name, m_asset.Type);
|
||||
/// for debugging purposes.
|
||||
/// </param>
|
||||
public AssetXferUploader(
|
||||
AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile)
|
||||
{
|
||||
m_asset = new AssetBase();
|
||||
|
||||
m_transactions = transactions;
|
||||
m_transactionID = transactionID;
|
||||
m_Scene = scene;
|
||||
m_asset = new AssetBase() { FullID = assetID };
|
||||
m_dumpAssetToFile = dumpAssetToFile;
|
||||
}
|
||||
|
||||
@@ -118,30 +154,50 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialise asset transfer from the client
|
||||
/// Start asset transfer from the client
|
||||
/// </summary>
|
||||
/// <param name="xferID"></param>
|
||||
/// <param name="packetID"></param>
|
||||
/// <param name="data"></param>
|
||||
public void Initialise(IClientAPI remoteClient, UUID assetID,
|
||||
UUID transaction, sbyte type, byte[] data, bool storeLocal,
|
||||
bool tempFile)
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="assetID"></param>
|
||||
/// <param name="transaction"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="data">
|
||||
/// Optional data. If present then the asset is created immediately with this data
|
||||
/// rather than requesting an upload from the client. The data must be longer than 2 bytes.
|
||||
/// </param>
|
||||
/// <param name="storeLocal"></param>
|
||||
/// <param name="tempFile"></param>
|
||||
public void StartUpload(
|
||||
IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal,
|
||||
bool tempFile)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}",
|
||||
// remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length);
|
||||
|
||||
lock (this)
|
||||
{
|
||||
if (m_uploadState != UploadState.New)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[ASSET XFER UPLOADER]: Tried to start upload of asset {0}, transaction {1} for {2} but this is already in state {3}. Aborting.",
|
||||
assetID, transaction, remoteClient.Name, m_uploadState);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_uploadState = UploadState.Uploading;
|
||||
}
|
||||
|
||||
ourClient = remoteClient;
|
||||
m_asset.Name = "blank";
|
||||
m_asset.Description = "empty";
|
||||
|
||||
m_asset.FullID = assetID;
|
||||
m_asset.Type = type;
|
||||
m_asset.CreatorID = remoteClient.AgentId.ToString();
|
||||
m_asset.Data = data;
|
||||
m_asset.Local = storeLocal;
|
||||
m_asset.Temporary = tempFile;
|
||||
|
||||
TransactionID = transaction;
|
||||
m_storeLocal = storeLocal;
|
||||
// m_storeLocal = storeLocal;
|
||||
|
||||
if (m_asset.Data.Length > 2)
|
||||
{
|
||||
@@ -166,36 +222,35 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
|
||||
protected void SendCompleteMessage()
|
||||
{
|
||||
ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true,
|
||||
m_asset.FullID);
|
||||
|
||||
// We must lock in order to avoid a race with a separate thread dealing with an inventory item or create
|
||||
// message from other client UDP.
|
||||
lock (this)
|
||||
{
|
||||
m_finished = true;
|
||||
m_uploadState = UploadState.Complete;
|
||||
|
||||
ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID);
|
||||
|
||||
if (m_createItem)
|
||||
{
|
||||
DoCreateItem(m_createItemCallback);
|
||||
CompleteCreateItem(m_createItemCallback);
|
||||
}
|
||||
else if (m_updateItem)
|
||||
{
|
||||
StoreAssetForItemUpdate(m_updateItemData);
|
||||
|
||||
// Remove ourselves from the list of transactions if completion was delayed until the transaction
|
||||
// was complete.
|
||||
// TODO: Should probably do the same for create item.
|
||||
m_transactions.RemoveXferUploader(TransactionID);
|
||||
CompleteItemUpdate(m_updateItemData);
|
||||
}
|
||||
else if (m_storeLocal)
|
||||
else if (m_updateTaskItem)
|
||||
{
|
||||
m_Scene.AssetService.Store(m_asset);
|
||||
CompleteTaskItemUpdate(m_updateTaskItemData);
|
||||
}
|
||||
// else if (m_storeLocal)
|
||||
// {
|
||||
// m_Scene.AssetService.Store(m_asset);
|
||||
// }
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[ASSET XFER UPLOADER]: Uploaded asset {0} for transaction {1}",
|
||||
m_asset.FullID, TransactionID);
|
||||
m_asset.FullID, m_transactionID);
|
||||
|
||||
if (m_dumpAssetToFile)
|
||||
{
|
||||
@@ -223,40 +278,37 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
}
|
||||
|
||||
public void RequestCreateInventoryItem(IClientAPI remoteClient,
|
||||
UUID transactionID, UUID folderID, uint callbackID,
|
||||
UUID folderID, uint callbackID,
|
||||
string description, string name, sbyte invType,
|
||||
sbyte type, byte wearableType, uint nextOwnerMask)
|
||||
{
|
||||
if (TransactionID == transactionID)
|
||||
{
|
||||
InventFolder = folderID;
|
||||
m_name = name;
|
||||
m_description = description;
|
||||
this.type = type;
|
||||
this.invType = invType;
|
||||
this.wearableType = wearableType;
|
||||
nextPerm = nextOwnerMask;
|
||||
m_asset.Name = name;
|
||||
m_asset.Description = description;
|
||||
m_asset.Type = type;
|
||||
InventFolder = folderID;
|
||||
m_name = name;
|
||||
m_description = description;
|
||||
this.type = type;
|
||||
this.invType = invType;
|
||||
this.wearableType = wearableType;
|
||||
nextPerm = nextOwnerMask;
|
||||
m_asset.Name = name;
|
||||
m_asset.Description = description;
|
||||
m_asset.Type = type;
|
||||
|
||||
// We must lock to avoid a race with a separate thread uploading the asset.
|
||||
lock (this)
|
||||
// We must lock to avoid a race with a separate thread uploading the asset.
|
||||
lock (this)
|
||||
{
|
||||
if (m_uploadState == UploadState.Complete)
|
||||
{
|
||||
if (m_finished)
|
||||
{
|
||||
DoCreateItem(callbackID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createItem = true; //set flag so the inventory item is created when upload is complete
|
||||
m_createItemCallback = callbackID;
|
||||
}
|
||||
CompleteCreateItem(callbackID);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createItem = true; //set flag so the inventory item is created when upload is complete
|
||||
m_createItemCallback = callbackID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item)
|
||||
public void RequestUpdateInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
|
||||
{
|
||||
// We must lock to avoid a race with a separate thread uploading the asset.
|
||||
lock (this)
|
||||
@@ -271,9 +323,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
item.AssetID = m_asset.FullID;
|
||||
m_Scene.InventoryService.UpdateItem(item);
|
||||
|
||||
if (m_finished)
|
||||
if (m_uploadState == UploadState.Complete)
|
||||
{
|
||||
StoreAssetForItemUpdate(item);
|
||||
CompleteItemUpdate(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,20 +339,59 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, TaskInventoryItem taskItem)
|
||||
{
|
||||
// We must lock to avoid a race with a separate thread uploading the asset.
|
||||
lock (this)
|
||||
{
|
||||
m_asset.Name = taskItem.Name;
|
||||
m_asset.Description = taskItem.Description;
|
||||
m_asset.Type = (sbyte)taskItem.Type;
|
||||
taskItem.AssetID = m_asset.FullID;
|
||||
|
||||
if (m_uploadState == UploadState.Complete)
|
||||
{
|
||||
CompleteTaskItemUpdate(taskItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_updateTaskItem = true;
|
||||
m_updateTaskItemData = taskItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store the asset for the given item.
|
||||
/// Store the asset for the given item when it has been uploaded.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
private void StoreAssetForItemUpdate(InventoryItemBase item)
|
||||
private void CompleteItemUpdate(InventoryItemBase item)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}",
|
||||
// m_asset.FullID, item.Name, ourClient.Name);
|
||||
|
||||
m_Scene.AssetService.Store(m_asset);
|
||||
|
||||
m_transactions.RemoveXferUploader(m_transactionID);
|
||||
}
|
||||
|
||||
private void DoCreateItem(uint callbackID)
|
||||
/// <summary>
|
||||
/// Store the asset for the given task item when it has been uploaded.
|
||||
/// </summary>
|
||||
/// <param name="taskItem"></param>
|
||||
private void CompleteTaskItemUpdate(TaskInventoryItem taskItem)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}",
|
||||
// m_asset.FullID, taskItem.Name, ourClient.Name);
|
||||
|
||||
m_Scene.AssetService.Store(m_asset);
|
||||
|
||||
m_transactions.RemoveXferUploader(m_transactionID);
|
||||
}
|
||||
|
||||
private void CompleteCreateItem(uint callbackID)
|
||||
{
|
||||
m_Scene.AssetService.Store(m_asset);
|
||||
|
||||
@@ -326,20 +417,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
ourClient.SendInventoryItemCreateUpdate(item, callbackID);
|
||||
else
|
||||
ourClient.SendAlertMessage("Unable to create inventory item");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the asset data uploaded in this transfer.
|
||||
/// </summary>
|
||||
/// <returns>null if the asset has not finished uploading</returns>
|
||||
public AssetBase GetAssetData()
|
||||
{
|
||||
if (m_finished)
|
||||
{
|
||||
return m_asset;
|
||||
}
|
||||
|
||||
return null;
|
||||
m_transactions.RemoveXferUploader(m_transactionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,8 +107,6 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
private IAssetService m_AssetService;
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
|
||||
private bool m_DeepScanBeforePurge;
|
||||
|
||||
public FlotsamAssetCache()
|
||||
{
|
||||
m_InvalidChars.AddRange(Path.GetInvalidPathChars());
|
||||
@@ -170,8 +168,6 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen);
|
||||
|
||||
m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt);
|
||||
|
||||
m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge);
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory);
|
||||
@@ -506,13 +502,10 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
// Purge all files last accessed prior to this point
|
||||
DateTime purgeLine = DateTime.Now - m_FileExpiration;
|
||||
|
||||
// An optional deep scan at this point will ensure assets present in scenes,
|
||||
// or referenced by objects in the scene, but not recently accessed
|
||||
// are not purged.
|
||||
if (m_DeepScanBeforePurge)
|
||||
{
|
||||
CacheScenes();
|
||||
}
|
||||
// An asset cache may contain local non-temporary assets that are not in the asset service. Therefore,
|
||||
// before cleaning up expired files we must scan the objects in the scene to make sure that we retain
|
||||
// such local assets if they have not been recently accessed.
|
||||
TouchAllSceneAssets(false);
|
||||
|
||||
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
|
||||
{
|
||||
@@ -705,11 +698,14 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
|
||||
/// <summary>
|
||||
/// Iterates through all Scenes, doing a deep scan through assets
|
||||
/// to cache all assets present in the scene or referenced by assets
|
||||
/// in the scene
|
||||
/// to update the access time of all assets present in the scene or referenced by assets
|
||||
/// in the scene.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private int CacheScenes()
|
||||
/// <param name="storeUncached">
|
||||
/// If true, then assets scanned which are not found in cache are added to the cache.
|
||||
/// </param>
|
||||
/// <returns>Number of distinct asset references found in the scene.</returns>
|
||||
private int TouchAllSceneAssets(bool storeUncached)
|
||||
{
|
||||
UuidGatherer gatherer = new UuidGatherer(m_AssetService);
|
||||
|
||||
@@ -732,7 +728,7 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
{
|
||||
File.SetLastAccessTime(filename, DateTime.Now);
|
||||
}
|
||||
else
|
||||
else if (storeUncached)
|
||||
{
|
||||
m_AssetService.Get(assetID.ToString());
|
||||
}
|
||||
@@ -860,13 +856,14 @@ namespace Flotsam.RegionModules.AssetCache
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "assets":
|
||||
m_log.Info("[FLOTSAM ASSET CACHE]: Caching all assets, in all scenes.");
|
||||
m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes.");
|
||||
|
||||
Util.FireAndForget(delegate {
|
||||
int assetsCached = CacheScenes();
|
||||
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached);
|
||||
int assetReferenceTotal = TouchAllSceneAssets(true);
|
||||
m_log.InfoFormat(
|
||||
"[FLOTSAM ASSET CACHE]: Completed check with {0} assets.",
|
||||
assetReferenceTotal);
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
@@ -48,14 +48,16 @@ namespace OpenSim.Region.CoreModules.Asset.Tests
|
||||
/// At the moment we're only test the in-memory part of the FlotsamAssetCache. This is a considerable weakness.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class FlotsamAssetCacheTests
|
||||
public class FlotsamAssetCacheTests : OpenSimTestCase
|
||||
{
|
||||
protected TestScene m_scene;
|
||||
protected FlotsamAssetCache m_cache;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
|
||||
config.AddConfig("Modules");
|
||||
|
||||
@@ -75,10 +75,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
m_scene.RegisterModuleInterface<IAttachmentsModule>(this);
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
|
||||
m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true);
|
||||
m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false);
|
||||
}
|
||||
|
||||
// TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Listen for client triggered running state changes so that we can persist the script's object if necessary.
|
||||
/// </summary>
|
||||
/// <param name='localID'></param>
|
||||
/// <param name='itemID'></param>
|
||||
private void HandleScriptStateChange(uint localID, bool started)
|
||||
{
|
||||
SceneObjectGroup sog = m_scene.GetGroupByPrim(localID);
|
||||
if (sog != null && sog.IsAttachment)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
// FIXME: This is a convoluted way for working out whether the script state has changed to stop
|
||||
// because it has been manually stopped or because the stop was called in UpdateDetachedObject() below
|
||||
// This needs to be handled in a less tangled way.
|
||||
ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar);
|
||||
if (sp.ControllingClient.IsActive)
|
||||
sog.HasGroupChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sog.HasGroupChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
@@ -531,9 +561,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
if (grp.HasGroupChanged)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||
// grp.UUID, grp.AttachmentPoint);
|
||||
m_log.DebugFormat(
|
||||
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||
grp.UUID, grp.AttachmentPoint);
|
||||
|
||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
|
||||
|
||||
@@ -637,7 +667,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
});
|
||||
}
|
||||
|
||||
so.IsSelected = false; // fudge....
|
||||
// Fudge below is an extremely unhelpful comment. It's probably here so that the scheduled full update
|
||||
// will succeed, as that will not update if an attachment is selected.
|
||||
so.IsSelected = false; // fudge....
|
||||
|
||||
so.ScheduleGroupForFullUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
|
||||
SceneObjectGroup rezzedAtt = presence.GetAttachments()[0];
|
||||
|
||||
scene.IncomingCloseAgent(presence.UUID);
|
||||
scene.IncomingCloseAgent(presence.UUID, false);
|
||||
|
||||
// Check that we can't retrieve this attachment from the scene.
|
||||
Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null);
|
||||
@@ -641,4 +641,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
// Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +262,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
// Replace an HG ID with the simple asset ID so that we can persist textures for foreign HG avatars
|
||||
asset.ID = asset.FullID.ToString();
|
||||
|
||||
asset.Temporary = false;
|
||||
asset.Local = false;
|
||||
m_scene.AssetService.Store(asset);
|
||||
|
||||
@@ -39,7 +39,7 @@ using OpenSim.Tests.Common.Mock;
|
||||
namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
{
|
||||
[TestFixture]
|
||||
public class AvatarFactoryModuleTests
|
||||
public class AvatarFactoryModuleTests : OpenSimTestCase
|
||||
{
|
||||
/// <summary>
|
||||
/// Only partial right now since we don't yet test that it's ended up in the avatar appearance service.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user