diff options
author | Justin Clark-Casey (justincc) | 2011-12-07 14:55:01 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-12-07 14:55:01 +0000 |
commit | a8ed185c00c3c688ae939104cc0cc752a430c168 (patch) | |
tree | 6da7bfadcae8fc8be6ac00b3d1f2eb6479611819 /OpenSim | |
parent | Stop also adding an ordinary http handler when we set up a poll http handler. (diff) | |
download | opensim-SC-a8ed185c00c3c688ae939104cc0cc752a430c168.zip opensim-SC-a8ed185c00c3c688ae939104cc0cc752a430c168.tar.gz opensim-SC-a8ed185c00c3c688ae939104cc0cc752a430c168.tar.bz2 opensim-SC-a8ed185c00c3c688ae939104cc0cc752a430c168.tar.xz |
properly lock CapsHandlers.m_capsHandlers
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Capabilities/CapsHandlers.cs | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/OpenSim/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs index a0e9ebc..1709f46 100644 --- a/OpenSim/Capabilities/CapsHandlers.cs +++ b/OpenSim/Capabilities/CapsHandlers.cs | |||
@@ -51,11 +51,10 @@ namespace OpenSim.Framework.Capabilities | |||
51 | /// supplied BaseHttpServer. | 51 | /// supplied BaseHttpServer. |
52 | /// </summary> | 52 | /// </summary> |
53 | /// <param name="httpListener">base HTTP server</param> | 53 | /// <param name="httpListener">base HTTP server</param> |
54 | /// <param name="httpListenerHostname">host name of the HTTP | 54 | /// <param name="httpListenerHostname">host name of the HTTP server</param> |
55 | /// server</param> | ||
56 | /// <param name="httpListenerPort">HTTP port</param> | 55 | /// <param name="httpListenerPort">HTTP port</param> |
57 | public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) | 56 | public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) |
58 | : this (httpListener,httpListenerHostname,httpListenerPort, false) | 57 | : this(httpListener,httpListenerHostname,httpListenerPort, false) |
59 | { | 58 | { |
60 | } | 59 | } |
61 | 60 | ||
@@ -88,44 +87,52 @@ namespace OpenSim.Framework.Capabilities | |||
88 | /// handler to be removed</param> | 87 | /// handler to be removed</param> |
89 | public void Remove(string capsName) | 88 | public void Remove(string capsName) |
90 | { | 89 | { |
91 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); | 90 | lock (m_capsHandlers) |
92 | m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); | 91 | { |
93 | m_capsHandlers.Remove(capsName); | 92 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); |
93 | m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); | ||
94 | m_capsHandlers.Remove(capsName); | ||
95 | } | ||
94 | } | 96 | } |
95 | 97 | ||
96 | public bool ContainsCap(string cap) | 98 | public bool ContainsCap(string cap) |
97 | { | 99 | { |
98 | return m_capsHandlers.ContainsKey(cap); | 100 | lock (m_capsHandlers) |
101 | return m_capsHandlers.ContainsKey(cap); | ||
99 | } | 102 | } |
100 | 103 | ||
101 | /// <summary> | 104 | /// <summary> |
102 | /// The indexer allows us to treat the CapsHandlers object | 105 | /// The indexer allows us to treat the CapsHandlers object |
103 | /// in an intuitive dictionary like way. | 106 | /// in an intuitive dictionary like way. |
104 | /// </summary> | 107 | /// </summary> |
105 | /// <Remarks> | 108 | /// <remarks> |
106 | /// The indexer will throw an exception when you try to | 109 | /// The indexer will throw an exception when you try to |
107 | /// retrieve a cap handler for a cap that is not contained in | 110 | /// retrieve a cap handler for a cap that is not contained in |
108 | /// CapsHandlers. | 111 | /// CapsHandlers. |
109 | /// </Remarks> | 112 | /// </remarks> |
110 | public IRequestHandler this[string idx] | 113 | public IRequestHandler this[string idx] |
111 | { | 114 | { |
112 | get | 115 | get |
113 | { | 116 | { |
114 | return m_capsHandlers[idx]; | 117 | lock (m_capsHandlers) |
118 | return m_capsHandlers[idx]; | ||
115 | } | 119 | } |
116 | 120 | ||
117 | set | 121 | set |
118 | { | 122 | { |
119 | if (m_capsHandlers.ContainsKey(idx)) | 123 | lock (m_capsHandlers) |
120 | { | 124 | { |
121 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); | 125 | if (m_capsHandlers.ContainsKey(idx)) |
122 | m_capsHandlers.Remove(idx); | 126 | { |
127 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); | ||
128 | m_capsHandlers.Remove(idx); | ||
129 | } | ||
130 | |||
131 | if (null == value) return; | ||
132 | |||
133 | m_capsHandlers[idx] = value; | ||
134 | m_httpListener.AddStreamHandler(value); | ||
123 | } | 135 | } |
124 | |||
125 | if (null == value) return; | ||
126 | |||
127 | m_capsHandlers[idx] = value; | ||
128 | m_httpListener.AddStreamHandler(value); | ||
129 | } | 136 | } |
130 | } | 137 | } |
131 | 138 | ||
@@ -137,9 +144,12 @@ namespace OpenSim.Framework.Capabilities | |||
137 | { | 144 | { |
138 | get | 145 | get |
139 | { | 146 | { |
140 | string[] __keys = new string[m_capsHandlers.Keys.Count]; | 147 | lock (m_capsHandlers) |
141 | m_capsHandlers.Keys.CopyTo(__keys, 0); | 148 | { |
142 | return __keys; | 149 | string[] __keys = new string[m_capsHandlers.Keys.Count]; |
150 | m_capsHandlers.Keys.CopyTo(__keys, 0); | ||
151 | return __keys; | ||
152 | } | ||
143 | } | 153 | } |
144 | } | 154 | } |
145 | 155 | ||
@@ -157,15 +167,19 @@ namespace OpenSim.Framework.Capabilities | |||
157 | protocol = "https://"; | 167 | protocol = "https://"; |
158 | 168 | ||
159 | string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); | 169 | string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); |
160 | foreach (string capsName in m_capsHandlers.Keys) | 170 | |
171 | lock (m_capsHandlers) | ||
161 | { | 172 | { |
162 | if (excludeSeed && "SEED" == capsName) | 173 | foreach (string capsName in m_capsHandlers.Keys) |
163 | continue; | 174 | { |
175 | if (excludeSeed && "SEED" == capsName) | ||
176 | continue; | ||
164 | 177 | ||
165 | caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; | 178 | caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; |
179 | } | ||
166 | } | 180 | } |
167 | 181 | ||
168 | return caps; | 182 | return caps; |
169 | } | 183 | } |
170 | } | 184 | } |
171 | } | 185 | } \ No newline at end of file |