Resolve a small race condition on removing bot behaviours that might leave previous behaviour active

Also closes behaviours on disconnect instead of interrupt, though this makes no practical difference.
If existing behaviour is None, other added behavious will not take affect until None is removed (as this is an infinite wait until interrupted).
bullet-2.82
Justin Clark-Casey (justincc) 2014-08-15 22:41:00 +01:00
parent e0c6bfa81e
commit 1d2933ca51
1 changed files with 3 additions and 2 deletions

View File

@ -214,10 +214,11 @@ namespace pCampBot
if (!updatedBehaviours.TryGetValue(abbreviatedName, out behaviour))
return false;
behaviour.Close();
updatedBehaviours.Remove(abbreviatedName);
Behaviours = updatedBehaviours;
behaviour.Close();
return true;
}
@ -299,7 +300,7 @@ namespace pCampBot
ConnectionState = ConnectionState.Disconnecting;
foreach (IBehaviour behaviour in Behaviours.Values)
behaviour.Interrupt();
behaviour.Close();
Client.Network.Logout();
}