mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Backport a bit of the backgroundtimer handling from 1.2 to better handle large sets of expiring tbans. Reported by wonderwal.
This commit is contained in:
parent
638ef62cd4
commit
aceb2c4846
@ -116,7 +116,6 @@ class ModuleTimedBans : public Module
|
||||
ModuleTimedBans(InspIRCd* Me)
|
||||
: Module(Me)
|
||||
{
|
||||
|
||||
mycommand = new cmd_tban(ServerInstance);
|
||||
ServerInstance->AddCommand(mycommand);
|
||||
TimedBanList.clear();
|
||||
@ -151,22 +150,18 @@ class ModuleTimedBans : public Module
|
||||
|
||||
virtual void OnBackgroundTimer(time_t curtime)
|
||||
{
|
||||
bool again = true;
|
||||
while (again)
|
||||
{
|
||||
again = false;
|
||||
for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
|
||||
for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end();)
|
||||
{
|
||||
if (curtime > i->expire)
|
||||
{
|
||||
chanrec* cr = ServerInstance->FindChan(i->channel);
|
||||
again = true;
|
||||
std::string chan = i->channel;
|
||||
std::string mask = i->mask;
|
||||
chanrec* cr = ServerInstance->FindChan(chan);
|
||||
i = TimedBanList.erase(i);
|
||||
if (cr)
|
||||
{
|
||||
const char *setban[3];
|
||||
std::string mask = i->mask;
|
||||
|
||||
setban[0] = i->channel.c_str();
|
||||
setban[0] = chan.c_str();
|
||||
setban[1] = "-b";
|
||||
setban[2] = mask.c_str();
|
||||
// kludge alert!
|
||||
@ -177,31 +172,21 @@ class ModuleTimedBans : public Module
|
||||
userrec* temp = new userrec(ServerInstance);
|
||||
CUList empty;
|
||||
temp->SetFd(FD_MAGIC_NUMBER);
|
||||
cr->WriteAllExcept(temp, true, '@', empty, "NOTICE %s :Timed ban on %s expired.", cr->name, i->mask.c_str());
|
||||
cr->WriteAllExcept(temp, true, '%', empty, "NOTICE %s :Timed ban on %s expired.", cr->name, i->mask.c_str());
|
||||
cr->WriteAllExcept(temp, true, '@', empty, "NOTICE %s :Timed ban on %s expired.", cr->name, setban[2]);
|
||||
cr->WriteAllExcept(temp, true, '%', empty, "NOTICE %s :Timed ban on %s expired.", cr->name, setban[2]);
|
||||
/* FIX: Send mode remotely*/
|
||||
std::deque<std::string> n;
|
||||
n.push_back(setban[0]);
|
||||
n.push_back("-b");
|
||||
n.push_back(setban[1]);
|
||||
n.push_back(setban[2]);
|
||||
ServerInstance->SendMode(setban,3,temp);
|
||||
Event rmode((char *)&n, NULL, "send_mode");
|
||||
rmode.Send(ServerInstance);
|
||||
DELETE(temp);
|
||||
|
||||
/* Fix for crash if user cycles before the ban expires */
|
||||
if (ServerInstance->Modes->GetLastParse().empty())
|
||||
TimedBanList.erase(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Where the hell did our channel go?! */
|
||||
TimedBanList.erase(i);
|
||||
}
|
||||
// we used to delete the item here, but we dont need to as the servermode above does it for us,
|
||||
break;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user