diff options
author | Adam <Adam@anope.org> | 2011-02-20 01:05:16 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-02-20 01:05:16 -0500 |
commit | c83b2b73d7c5f264dedb67b878d116b5b10a4742 (patch) | |
tree | 407251a2bb3bf738194b6ec7654b0872b6bab1d5 /modules/extra/m_mysql.cpp | |
parent | dfbb5264fac5b418da536cc968aed4bf5cde8b76 (diff) |
Much more work on the live SQL. Should work pretty decently now under heavy load.
Diffstat (limited to 'modules/extra/m_mysql.cpp')
-rw-r--r-- | modules/extra/m_mysql.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 12b4dbcc5..7ef4243e6 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -50,16 +50,13 @@ class MySQLResult : public SQLResult public: MySQLResult(const Anope::string &q, MYSQL_RES *r) : SQLResult(q), res(r) { - if (!res) - return; + unsigned num_fields = res ? mysql_num_fields(res) : 0; - unsigned num_fields = mysql_num_fields(res); + Log(LOG_DEBUG) << "SQL query " << q << " returned " << num_fields << " fields"; if (!num_fields) return; - Log(LOG_DEBUG) << "SQL query returned " << num_fields << " fields"; - for (MYSQL_ROW row; (row = mysql_fetch_row(res));) { MYSQL_FIELD *fields = mysql_fetch_fields(res); @@ -268,6 +265,8 @@ class ModuleSQL : public Module } this->DThread->Unlock(); + + this->SQLPipe->OnNotify(); } }; @@ -398,8 +397,11 @@ void DispatcherThread::Run() void MySQLPipe::OnNotify() { me->DThread->Lock(); + std::deque<QueryResult> finishedRequests = me->FinishedRequests; + me->FinishedRequests.clear(); + me->DThread->Unlock(); - for (std::deque<QueryResult>::const_iterator it = me->FinishedRequests.begin(), it_end = me->FinishedRequests.end(); it != it_end; ++it) + for (std::deque<QueryResult>::const_iterator it = finishedRequests.begin(), it_end = finishedRequests.end(); it != it_end; ++it) { const QueryResult &qr = *it; @@ -411,9 +413,6 @@ void MySQLPipe::OnNotify() else qr.sqlinterface->OnError(qr.result); } - me->FinishedRequests.clear(); - - me->DThread->Unlock(); } MODULE_INIT(ModuleSQL) |