Sfoglia il codice sorgente

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

tags/3.1.1
Teknikode 4 anni fa
parent
commit
a0e8eea8bb
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3
    0
      Combot/Bot.cs

+ 3
- 0
Combot/Bot.cs Vedi 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…
Annulla
Salva