diff options
author | Diva Canto | 2009-10-06 15:39:53 -0700 |
---|---|---|
committer | Diva Canto | 2009-10-06 15:39:53 -0700 |
commit | e992ca025571a891333a57012c2cd4419b6581e5 (patch) | |
tree | a6fd7e9f2e46999c72780bf60d2890e8a9c74fe4 /OpenSim/Region/ClientStack | |
parent | * Change some more default ports to the robust default of 8003 (diff) | |
download | opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.zip opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.gz opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.bz2 opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.xz |
Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 116 |
1 files changed, 69 insertions, 47 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 0052729..fe37a08 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -3122,6 +3122,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3122 | objectData.TextureAnim = textureanim; | 3122 | objectData.TextureAnim = textureanim; |
3123 | } | 3123 | } |
3124 | 3124 | ||
3125 | bool doUpdate = false; | ||
3125 | lock (m_primFullUpdates) | 3126 | lock (m_primFullUpdates) |
3126 | { | 3127 | { |
3127 | if (m_primFullUpdates.Count == 0) | 3128 | if (m_primFullUpdates.Count == 0) |
@@ -3130,8 +3131,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3130 | m_primFullUpdates.Add(objectData); | 3131 | m_primFullUpdates.Add(objectData); |
3131 | 3132 | ||
3132 | if (m_primFullUpdates.Count >= m_primFullUpdatesPerPacket) | 3133 | if (m_primFullUpdates.Count >= m_primFullUpdatesPerPacket) |
3133 | ProcessPrimFullUpdates(this, null); | 3134 | doUpdate = true; |
3134 | } | 3135 | } |
3136 | if (doUpdate) | ||
3137 | ProcessPrimFullUpdates(this, null); | ||
3135 | } | 3138 | } |
3136 | 3139 | ||
3137 | void HandleQueueEmpty(ThrottleOutPacketType queue) | 3140 | void HandleQueueEmpty(ThrottleOutPacketType queue) |
@@ -3152,35 +3155,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3152 | 3155 | ||
3153 | void ProcessPrimFullUpdates(object sender, ElapsedEventArgs e) | 3156 | void ProcessPrimFullUpdates(object sender, ElapsedEventArgs e) |
3154 | { | 3157 | { |
3158 | bool stopTimer = false; | ||
3155 | lock (m_primFullUpdates) | 3159 | lock (m_primFullUpdates) |
3156 | { | 3160 | { |
3157 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) | 3161 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) |
3158 | { | 3162 | stopTimer = true; |
3159 | lock (m_primFullUpdateTimer) | 3163 | } |
3160 | m_primFullUpdateTimer.Stop(); | 3164 | if (stopTimer) |
3161 | 3165 | { | |
3162 | return; | 3166 | lock (m_primFullUpdateTimer) |
3163 | } | 3167 | m_primFullUpdateTimer.Stop(); |
3168 | return; | ||
3169 | } | ||
3164 | 3170 | ||
3165 | ObjectUpdatePacket outPacket = | 3171 | ObjectUpdatePacket outPacket = |
3166 | (ObjectUpdatePacket)PacketPool.Instance.GetPacket( | 3172 | (ObjectUpdatePacket)PacketPool.Instance.GetPacket( |
3167 | PacketType.ObjectUpdate); | 3173 | PacketType.ObjectUpdate); |
3168 | 3174 | ||
3169 | outPacket.RegionData.RegionHandle = | 3175 | outPacket.RegionData.RegionHandle = |
3170 | Scene.RegionInfo.RegionHandle; | 3176 | Scene.RegionInfo.RegionHandle; |
3171 | outPacket.RegionData.TimeDilation = | 3177 | outPacket.RegionData.TimeDilation = |
3172 | (ushort)(Scene.TimeDilation * ushort.MaxValue); | 3178 | (ushort)(Scene.TimeDilation * ushort.MaxValue); |
3173 | 3179 | ||
3174 | int max = m_primFullUpdates.Count; | 3180 | int max = m_primFullUpdates.Count; |
3175 | if (max > m_primFullUpdatesPerPacket) | 3181 | if (max > m_primFullUpdatesPerPacket) |
3176 | max = m_primFullUpdatesPerPacket; | 3182 | max = m_primFullUpdatesPerPacket; |
3177 | 3183 | ||
3178 | int count = 0; | 3184 | int count = 0; |
3179 | int size = 0; | 3185 | int size = 0; |
3180 | 3186 | ||
3181 | byte[] zerobuffer = new byte[1024]; | 3187 | byte[] zerobuffer = new byte[1024]; |
3182 | byte[] blockbuffer = new byte[1024]; | 3188 | byte[] blockbuffer = new byte[1024]; |
3183 | 3189 | ||
3190 | lock (m_primFullUpdates) | ||
3191 | { | ||
3184 | for (count = 0 ; count < max ; count++) | 3192 | for (count = 0 ; count < max ; count++) |
3185 | { | 3193 | { |
3186 | int length = 0; | 3194 | int length = 0; |
@@ -3204,9 +3212,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3204 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); | 3212 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); |
3205 | 3213 | ||
3206 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) | 3214 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) |
3207 | lock (m_primFullUpdateTimer) | 3215 | stopTimer = true; |
3208 | m_primFullUpdateTimer.Stop(); | ||
3209 | } | 3216 | } |
3217 | |||
3218 | if (stopTimer) | ||
3219 | lock (m_primFullUpdateTimer) | ||
3220 | m_primFullUpdateTimer.Stop(); | ||
3210 | } | 3221 | } |
3211 | 3222 | ||
3212 | /// <summary> | 3223 | /// <summary> |
@@ -3225,6 +3236,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3225 | CreatePrimImprovedBlock(localID, position, rotation, | 3236 | CreatePrimImprovedBlock(localID, position, rotation, |
3226 | velocity, rotationalvelocity, state); | 3237 | velocity, rotationalvelocity, state); |
3227 | 3238 | ||
3239 | bool doUpdate = false; | ||
3228 | lock (m_primTerseUpdates) | 3240 | lock (m_primTerseUpdates) |
3229 | { | 3241 | { |
3230 | if (m_primTerseUpdates.Count == 0) | 3242 | if (m_primTerseUpdates.Count == 0) |
@@ -3233,43 +3245,51 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3233 | m_primTerseUpdates.Add(objectData); | 3245 | m_primTerseUpdates.Add(objectData); |
3234 | 3246 | ||
3235 | if (m_primTerseUpdates.Count >= m_primTerseUpdatesPerPacket) | 3247 | if (m_primTerseUpdates.Count >= m_primTerseUpdatesPerPacket) |
3236 | ProcessPrimTerseUpdates(this, null); | 3248 | doUpdate = true; |
3237 | } | 3249 | } |
3250 | if (doUpdate) | ||
3251 | ProcessPrimTerseUpdates(this, null); | ||
3238 | } | 3252 | } |
3239 | 3253 | ||
3240 | void ProcessPrimTerseUpdates(object sender, ElapsedEventArgs e) | 3254 | void ProcessPrimTerseUpdates(object sender, ElapsedEventArgs e) |
3241 | { | 3255 | { |
3256 | bool stopTimer = false; | ||
3242 | lock (m_primTerseUpdates) | 3257 | lock (m_primTerseUpdates) |
3243 | { | 3258 | { |
3244 | if (m_primTerseUpdates.Count == 0) | 3259 | if (m_primTerseUpdates.Count == 0) |
3245 | { | 3260 | stopTimer = true; |
3246 | lock (m_primTerseUpdateTimer) | 3261 | } |
3247 | m_primTerseUpdateTimer.Stop(); | 3262 | if (stopTimer) |
3263 | { | ||
3264 | lock (m_primTerseUpdateTimer) | ||
3265 | m_primTerseUpdateTimer.Stop(); | ||
3248 | 3266 | ||
3249 | return; | 3267 | return; |
3250 | } | 3268 | } |
3251 | 3269 | ||
3252 | ImprovedTerseObjectUpdatePacket outPacket = | 3270 | ImprovedTerseObjectUpdatePacket outPacket = |
3253 | (ImprovedTerseObjectUpdatePacket) | 3271 | (ImprovedTerseObjectUpdatePacket) |
3254 | PacketPool.Instance.GetPacket( | 3272 | PacketPool.Instance.GetPacket( |
3255 | PacketType.ImprovedTerseObjectUpdate); | 3273 | PacketType.ImprovedTerseObjectUpdate); |
3256 | 3274 | ||
3257 | outPacket.RegionData.RegionHandle = | 3275 | outPacket.RegionData.RegionHandle = |
3258 | Scene.RegionInfo.RegionHandle; | 3276 | Scene.RegionInfo.RegionHandle; |
3259 | outPacket.RegionData.TimeDilation = | 3277 | outPacket.RegionData.TimeDilation = |
3260 | (ushort)(Scene.TimeDilation * ushort.MaxValue); | 3278 | (ushort)(Scene.TimeDilation * ushort.MaxValue); |
3261 | 3279 | ||
3262 | int max = m_primTerseUpdates.Count; | 3280 | int max = m_primTerseUpdates.Count; |
3263 | if (max > m_primTerseUpdatesPerPacket) | 3281 | if (max > m_primTerseUpdatesPerPacket) |
3264 | max = m_primTerseUpdatesPerPacket; | 3282 | max = m_primTerseUpdatesPerPacket; |
3265 | 3283 | ||
3266 | int count = 0; | 3284 | int count = 0; |
3267 | int size = 0; | 3285 | int size = 0; |
3268 | 3286 | ||
3269 | byte[] zerobuffer = new byte[1024]; | 3287 | byte[] zerobuffer = new byte[1024]; |
3270 | byte[] blockbuffer = new byte[1024]; | 3288 | byte[] blockbuffer = new byte[1024]; |
3271 | 3289 | ||
3272 | for (count = 0 ; count < max ; count++) | 3290 | lock (m_primTerseUpdates) |
3291 | { | ||
3292 | for (count = 0; count < max; count++) | ||
3273 | { | 3293 | { |
3274 | int length = 0; | 3294 | int length = 0; |
3275 | m_primTerseUpdates[count].ToBytes(blockbuffer, ref length); | 3295 | m_primTerseUpdates[count].ToBytes(blockbuffer, ref length); |
@@ -3294,9 +3314,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3294 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); | 3314 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); |
3295 | 3315 | ||
3296 | if (m_primTerseUpdates.Count == 0) | 3316 | if (m_primTerseUpdates.Count == 0) |
3297 | lock (m_primTerseUpdateTimer) | 3317 | stopTimer = true; |
3298 | m_primTerseUpdateTimer.Stop(); | ||
3299 | } | 3318 | } |
3319 | if (stopTimer) | ||
3320 | lock (m_primTerseUpdateTimer) | ||
3321 | m_primTerseUpdateTimer.Stop(); | ||
3300 | } | 3322 | } |
3301 | 3323 | ||
3302 | public void FlushPrimUpdates() | 3324 | public void FlushPrimUpdates() |