Browse Source

Spam Control - Added lock around spam session list to prevent exceptions.

tags/3.1.1
Teknikode 4 years ago
parent
commit
a0e8eea8bb
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      Combot/Bot.cs

+ 3
- 0
Combot/Bot.cs View File

@@ -37,6 +37,7 @@ namespace Combot
private int RetryCount;
private bool RetryAllowed;
private Dictionary<string, SpamSession> SpamSessions;
private ReaderWriterLockSlim SpamSessionLock = new ReaderWriterLockSlim();

public Bot(ServerConfig serverConfig)
{
@@ -467,6 +468,7 @@ namespace Combot
source = command.Name;
break;
}
SpamSessionLock.EnterWriteLock();
if (SpamSessions.ContainsKey(source))
{
SpamSession session = SpamSessions[source];
@@ -494,6 +496,7 @@ namespace Combot
{
SpamSessions.Add(source, new SpamSession());
}
SpamSessionLock.ExitWriteLock();

return allowed;
}

Loading…
Cancel
Save