From 5b58df4f5bc09138b22c6e9762c40ef6c5b05931 Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Sat, 26 Dec 2020 13:38:31 +0000 Subject: [PATCH] adds some locks to stop threading issues --- Core/bottypes/AVstorageBot.cs | 32 +++++++++++++++++++------------- Core/bottypes/AnimationsBot.cs | 11 +++++++---- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Core/bottypes/AVstorageBot.cs b/Core/bottypes/AVstorageBot.cs index b9402ac..e915844 100644 --- a/Core/bottypes/AVstorageBot.cs +++ b/Core/bottypes/AVstorageBot.cs @@ -127,19 +127,25 @@ namespace BSB.bottypes } } } - foreach(string purge in PurgeAvatars) - { - if (purge != myconfig.Security_MasterUsername) - { - if (AvatarStorageLastUsed.ContainsKey(purge) == true) - { - if(AvatarName2Key.ContainsKey(purge) == true) - { - AvatarStorageLastUsed.Remove(purge); - UUID avuuid = AvatarName2Key[purge]; - AvatarName2Key.Remove(purge); - AvatarKey2Name.Remove(avuuid); - } + lock (AvatarName2Key) + { + lock (AvatarStorageLastUsed) + { + foreach (string purge in PurgeAvatars) + { + if (purge != myconfig.Security_MasterUsername) + { + if (AvatarStorageLastUsed.ContainsKey(purge) == true) + { + if (AvatarName2Key.ContainsKey(purge) == true) + { + AvatarStorageLastUsed.Remove(purge); + UUID avuuid = AvatarName2Key[purge]; + AvatarName2Key.Remove(purge); + AvatarKey2Name.Remove(avuuid); + } + } + } } } } diff --git a/Core/bottypes/AnimationsBot.cs b/Core/bottypes/AnimationsBot.cs index 0b1ccac..a79a0a6 100644 --- a/Core/bottypes/AnimationsBot.cs +++ b/Core/bottypes/AnimationsBot.cs @@ -20,11 +20,14 @@ namespace BSB.bottypes public override void ResetAnimations() { - foreach (UUID ani in active_animations) - { - Client.Self.AnimationStop(ani, true); + lock (active_animations) + { + foreach (UUID ani in active_animations) + { + Client.Self.AnimationStop(ani, true); + } + active_animations.Clear(); } - active_animations.Clear(); } protected override void AvatarAnimationHandler(object sender, AvatarAnimationEventArgs e)