From e57e9e95d4cd8fd431eab79d41169827dfcbf8ab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Aug 2014 01:06:22 +0100 Subject: Allow "show bots" pCampbot console command to quickly report status by not locking entire bot list for almost 100% of connection time. --- OpenSim/Tools/pCampBot/BotManager.cs | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 8abab1d..f54d586 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -333,31 +333,33 @@ namespace pCampBot m_log.DebugFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates); m_log.DebugFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures); - int connectedBots = 0; + List botsToConnect = new List(); - for (int i = 0; i < m_bots.Count; i++) + lock (m_bots) { - lock (m_bots) + foreach (Bot bot in m_bots) { - if (DisconnectingBots) - { - MainConsole.Instance.Output( - "[BOT MANAGER]: Aborting bot connection due to user-initiated disconnection"); + if (bot.ConnectionState == ConnectionState.Disconnected) + botsToConnect.Add(bot); + + if (botsToConnect.Count >= botCount) break; - } + } + } - if (m_bots[i].ConnectionState == ConnectionState.Disconnected) - { - m_bots[i].Connect(); - connectedBots++; + foreach (Bot bot in botsToConnect) + { + if (DisconnectingBots) + { + MainConsole.Instance.Output( + "[BOT MANAGER]: Aborting bot connection due to user-initiated disconnection"); + break; + } - if (connectedBots >= botCount) - break; + bot.Connect(); - // Stagger logins - Thread.Sleep(LoginDelay); - } - } + // Stagger logins + Thread.Sleep(LoginDelay); } ConnectingBots = false; -- cgit v1.1