aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/extra/m_mysql.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-04-06 20:06:18 +0100
committerGravatar Sadie Powell2021-04-07 10:36:11 +0100
commit942fd2bcfd384a12c900999fe663202c87319a68 (patch)
treec2bad1906af27afbc3c7d96c3e5ca3c27c83f090 /src/modules/extra/m_mysql.cpp
parentMerge branch 'insp3' into master. (diff)
Switch simple iterator loops to use range-based for loops.
Diffstat (limited to 'src/modules/extra/m_mysql.cpp')
-rw-r--r--src/modules/extra/m_mysql.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 728f5a04a..6414434fb 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -455,10 +455,8 @@ ModuleSQL::~ModuleSQL()
delete Dispatcher;
}
- for(ConnMap::iterator i = connections.begin(); i != connections.end(); i++)
- {
- delete i->second;
- }
+ for (const auto& [_, connection] : connections)
+ delete connection;
mysql_library_end();
}
@@ -490,17 +488,18 @@ void ModuleSQL::ReadConfig(ConfigStatus& status)
// now clean up the deleted databases
Dispatcher->LockQueue();
SQL::Error err(SQL::BAD_DBID);
- for(ConnMap::iterator i = connections.begin(); i != connections.end(); i++)
+
+ for (const auto& [_, connection] : connections)
{
- ServerInstance->Modules.DelService(*i->second);
+ ServerInstance->Modules.DelService(*connection);
// it might be running a query on this database. Wait for that to complete
- i->second->lock.lock();
- i->second->lock.unlock();
+ connection->lock.lock();
+ connection->lock.unlock();
// now remove all active queries to this DB
for (size_t j = qq.size(); j > 0; j--)
{
size_t k = j - 1;
- if (qq[k].connection == i->second)
+ if (qq[k].connection == connection)
{
qq[k].query->OnError(err);
delete qq[k].query;
@@ -508,7 +507,7 @@ void ModuleSQL::ReadConfig(ConfigStatus& status)
}
}
// finally, nuke the connection
- delete i->second;
+ delete connection;
}
Dispatcher->UnlockQueue();
connections.swap(conns);
@@ -587,15 +586,15 @@ void DispatcherThread::OnNotify()
{
// this could unlock during the dispatch, but OnResult isn't expected to take that long
this->LockQueue();
- for(ResultQueue::iterator i = Parent->rq.begin(); i != Parent->rq.end(); i++)
+ for (const auto& item : Parent->rq)
{
- MySQLresult* res = i->result;
+ MySQLresult* res = item.result;
if (res->err.code == SQL::SUCCESS)
- i->query->OnResult(*res);
+ item.query->OnResult(*res);
else
- i->query->OnError(res->err);
- delete i->query;
- delete i->result;
+ item.query->OnError(res->err);
+ delete item.query;
+ delete item.result;
}
Parent->rq.clear();
this->UnlockQueue();