瀏覽代碼

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

tags/3.1.1
Teknikode 4 年之前
父節點
當前提交
a0e8eea8bb
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3
    0
      Combot/Bot.cs

+ 3
- 0
Combot/Bot.cs 查看文件

@@ -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…
取消
儲存