diff options
author | Justin Clark-Casey (justincc) | 2011-08-22 01:52:08 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-22 01:52:08 +0100 |
commit | 8254116dc6ca0be85caac6fbf26dfa4b82fef03d (patch) | |
tree | 80d4a38959c7b318f2222b8c49ddefff7ac32a28 /OpenSim | |
parent | minor: remove mono compiler warning (diff) | |
download | opensim-SC_OLD-8254116dc6ca0be85caac6fbf26dfa4b82fef03d.zip opensim-SC_OLD-8254116dc6ca0be85caac6fbf26dfa4b82fef03d.tar.gz opensim-SC_OLD-8254116dc6ca0be85caac6fbf26dfa4b82fef03d.tar.bz2 opensim-SC_OLD-8254116dc6ca0be85caac6fbf26dfa4b82fef03d.tar.xz |
improve locking of m_llsdHandlers in BaseHttpServer
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b3c05a0..897ee4f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -285,7 +285,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
285 | 285 | ||
286 | public List<string> GetLLSDHandlerKeys() | 286 | public List<string> GetLLSDHandlerKeys() |
287 | { | 287 | { |
288 | return new List<string>(m_llsdHandlers.Keys); | 288 | lock (m_llsdHandlers) |
289 | return new List<string>(m_llsdHandlers.Keys); | ||
289 | } | 290 | } |
290 | 291 | ||
291 | public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) | 292 | public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) |
@@ -1107,7 +1108,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1107 | /// <returns>true if we have one, false if not</returns> | 1108 | /// <returns>true if we have one, false if not</returns> |
1108 | private bool DoWeHaveALLSDHandler(string path) | 1109 | private bool DoWeHaveALLSDHandler(string path) |
1109 | { | 1110 | { |
1110 | |||
1111 | string[] pathbase = path.Split('/'); | 1111 | string[] pathbase = path.Split('/'); |
1112 | string searchquery = "/"; | 1112 | string searchquery = "/"; |
1113 | 1113 | ||
@@ -1123,14 +1123,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1123 | 1123 | ||
1124 | string bestMatch = null; | 1124 | string bestMatch = null; |
1125 | 1125 | ||
1126 | foreach (string pattern in m_llsdHandlers.Keys) | 1126 | lock (m_llsdHandlers) |
1127 | { | 1127 | { |
1128 | 1128 | foreach (string pattern in m_llsdHandlers.Keys) | |
1129 | if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) | ||
1130 | { | 1129 | { |
1131 | 1130 | if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) | |
1132 | bestMatch = pattern; | 1131 | bestMatch = pattern; |
1133 | |||
1134 | } | 1132 | } |
1135 | } | 1133 | } |
1136 | 1134 | ||
@@ -1143,12 +1141,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1143 | 1141 | ||
1144 | if (String.IsNullOrEmpty(bestMatch)) | 1142 | if (String.IsNullOrEmpty(bestMatch)) |
1145 | { | 1143 | { |
1146 | |||
1147 | return false; | 1144 | return false; |
1148 | } | 1145 | } |
1149 | else | 1146 | else |
1150 | { | 1147 | { |
1151 | |||
1152 | return true; | 1148 | return true; |
1153 | } | 1149 | } |
1154 | } | 1150 | } |
@@ -1233,29 +1229,32 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1233 | 1229 | ||
1234 | string bestMatch = null; | 1230 | string bestMatch = null; |
1235 | 1231 | ||
1236 | foreach (string pattern in m_llsdHandlers.Keys) | 1232 | lock (m_llsdHandlers) |
1237 | { | 1233 | { |
1238 | if (searchquery.ToLower().StartsWith(pattern.ToLower())) | 1234 | foreach (string pattern in m_llsdHandlers.Keys) |
1239 | { | 1235 | { |
1240 | if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) | 1236 | if (searchquery.ToLower().StartsWith(pattern.ToLower())) |
1241 | { | 1237 | { |
1242 | // You have to specifically register for '/' and to get it, you must specificaly request it | 1238 | if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) |
1243 | // | 1239 | { |
1244 | if (pattern == "/" && searchquery == "/" || pattern != "/") | 1240 | // You have to specifically register for '/' and to get it, you must specificaly request it |
1245 | bestMatch = pattern; | 1241 | // |
1242 | if (pattern == "/" && searchquery == "/" || pattern != "/") | ||
1243 | bestMatch = pattern; | ||
1244 | } | ||
1246 | } | 1245 | } |
1247 | } | 1246 | } |
1248 | } | 1247 | |
1249 | 1248 | if (String.IsNullOrEmpty(bestMatch)) | |
1250 | if (String.IsNullOrEmpty(bestMatch)) | 1249 | { |
1251 | { | 1250 | llsdHandler = null; |
1252 | llsdHandler = null; | 1251 | return false; |
1253 | return false; | 1252 | } |
1254 | } | 1253 | else |
1255 | else | 1254 | { |
1256 | { | 1255 | llsdHandler = m_llsdHandlers[bestMatch]; |
1257 | llsdHandler = m_llsdHandlers[bestMatch]; | 1256 | return true; |
1258 | return true; | 1257 | } |
1259 | } | 1258 | } |
1260 | } | 1259 | } |
1261 | 1260 | ||
@@ -1856,10 +1855,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1856 | { | 1855 | { |
1857 | try | 1856 | try |
1858 | { | 1857 | { |
1859 | if (handler == m_llsdHandlers[path]) | 1858 | lock (m_llsdHandlers) |
1860 | { | 1859 | { |
1861 | m_llsdHandlers.Remove(path); | 1860 | if (handler == m_llsdHandlers[path]) |
1862 | return true; | 1861 | { |
1862 | m_llsdHandlers.Remove(path); | ||
1863 | return true; | ||
1864 | } | ||
1863 | } | 1865 | } |
1864 | } | 1866 | } |
1865 | catch (KeyNotFoundException) | 1867 | catch (KeyNotFoundException) |