summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-02-25 21:41:08 -0500
committerAdam <Adam@anope.org>2011-02-25 21:41:08 -0500
commitc38b6392c5956628f51faaa6085367dd32199e61 (patch)
tree8933d0997016756b15e10a7ad88a5d51c04d841e /modules
parentee387569821b45581063f6bc349cccc643f9a293 (diff)
More fixes. Also made db_mysql_live not keep bots updated because thats pointless and made m_asynch_commands respect user language settings.
Diffstat (limited to 'modules')
-rw-r--r--modules/core/cs_list.cpp2
-rw-r--r--modules/core/cs_saset.cpp2
-rw-r--r--modules/core/cs_set.cpp2
-rw-r--r--modules/core/ns_list.cpp2
-rw-r--r--modules/core/ns_saset.cpp2
-rw-r--r--modules/core/ns_set.cpp2
-rw-r--r--modules/extra/db_mysql_live.cpp81
-rw-r--r--modules/extra/m_async_commands.cpp49
-rw-r--r--modules/extra/m_xmlrpc_main.cpp2
-rw-r--r--modules/protocol/inspircd11.cpp6
-rw-r--r--modules/protocol/inspircd12.cpp6
-rw-r--r--modules/protocol/inspircd20.cpp6
12 files changed, 61 insertions, 101 deletions
diff --git a/modules/core/cs_list.cpp b/modules/core/cs_list.cpp
index a330b5edd..4f1a95952 100644
--- a/modules/core/cs_list.cpp
+++ b/modules/core/cs_list.cpp
@@ -37,7 +37,7 @@ class CommandCSList : public Command
if (Config->CSListOpersOnly && !u->HasMode(UMODE_OPER))
{
source.Reply(LanguageString::ACCESS_DENIED);
- return MOD_STOP;
+ return MOD_CONT;
}
if (pattern[0] == '#')
diff --git a/modules/core/cs_saset.cpp b/modules/core/cs_saset.cpp
index 50a6f0bc9..876a487a3 100644
--- a/modules/core/cs_saset.cpp
+++ b/modules/core/cs_saset.cpp
@@ -55,7 +55,7 @@ class CommandCSSASet : public Command
for (std::vector<Anope::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it)
cmdparams += " " + *it;
Log(LOG_ADMIN, u, this, ci) << params[1] << " " << cmdparams;
- mod_run_cmd(ChanServ, u, c, params[1], cmdparams, false);
+ mod_run_cmd(ChanServ, u, NULL, c, params[1], cmdparams);
}
else
{
diff --git a/modules/core/cs_set.cpp b/modules/core/cs_set.cpp
index 55817d219..e089d4a2a 100644
--- a/modules/core/cs_set.cpp
+++ b/modules/core/cs_set.cpp
@@ -59,7 +59,7 @@ class CommandCSSet : public Command
Anope::string cmdparams = ci->name;
for (std::vector<Anope::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it)
cmdparams += " " + *it;
- mod_run_cmd(ChanServ, u, c, params[1], cmdparams, false);
+ mod_run_cmd(ChanServ, u, NULL, c, params[1], cmdparams);
}
else
{
diff --git a/modules/core/ns_list.cpp b/modules/core/ns_list.cpp
index 7350a471c..9d49ce2f5 100644
--- a/modules/core/ns_list.cpp
+++ b/modules/core/ns_list.cpp
@@ -53,7 +53,7 @@ class CommandNSList : public Command
if (Config->NSListOpersOnly && !u->HasMode(UMODE_OPER)) /* reverse the help logic */
{
source.Reply(LanguageString::ACCESS_DENIED);
- return MOD_STOP;
+ return MOD_CONT;
}
if (pattern[0] == '#')
diff --git a/modules/core/ns_saset.cpp b/modules/core/ns_saset.cpp
index 0aeab4d95..993a090fc 100644
--- a/modules/core/ns_saset.cpp
+++ b/modules/core/ns_saset.cpp
@@ -62,7 +62,7 @@ class CommandNSSASet : public Command
Log(LOG_ADMIN, u, this) << params[1] << " " << cmdparams;
else
Log(LOG_ADMIN, u, this) << params[1] << " for " << params[0];
- mod_run_cmd(NickServ, u, c, params[1], cmdparams, false);
+ mod_run_cmd(NickServ, u, NULL, c, params[1], cmdparams);
}
else
source.Reply(_("Unknown SASET option \002%s\002."), cmd.c_str());
diff --git a/modules/core/ns_set.cpp b/modules/core/ns_set.cpp
index 3bd9a0eae..86272c084 100644
--- a/modules/core/ns_set.cpp
+++ b/modules/core/ns_set.cpp
@@ -57,7 +57,7 @@ class CommandNSSet : public Command
Log(LOG_COMMAND, u, this) << params[0] << " " << cmdparams;
else
Log(LOG_COMMAND, u, this) << params[0];
- mod_run_cmd(NickServ, u, c, params[0], cmdparams, false);
+ mod_run_cmd(NickServ, u, NULL, c, params[0], cmdparams);
}
else
source.Reply(LanguageString::NICK_SET_UNKNOWN_OPTION, params[0].c_str());
diff --git a/modules/extra/db_mysql_live.cpp b/modules/extra/db_mysql_live.cpp
index c5e645be6..30e5a93c7 100644
--- a/modules/extra/db_mysql_live.cpp
+++ b/modules/extra/db_mysql_live.cpp
@@ -33,43 +33,6 @@ class SQLCache : public Timer
}
};
-class BotInfoUpdater : public SQLInterface, public SQLCache
-{
- public:
- BotInfoUpdater(Module *m) : SQLInterface(m) { }
-
- void OnResult(const SQLResult &r)
- {
- BotInfoUpdater::Process(r);
- }
-
- static void Process(const SQLResult &res)
- {
- try
- {
- BotInfo *bi = findbot(res.Get(0, "nick"));
- if (!bi)
- bi = new BotInfo(res.Get(0, "nick"), res.Get(0, "user"), res.Get(0, "host"), res.Get(0, "rname"));
- else
- {
- bi->SetIdent(res.Get(0, "user"));
- bi->host = res.Get(0, "host");
- bi->realname = res.Get(0, "rname");
- }
-
- if (res.Get(0, "flags").equals_cs("PRIVATE"))
- bi->SetFlag(BI_PRIVATE);
- bi->created = convertTo<time_t>(res.Get(0, "created"));
- bi->chancount = convertTo<uint32>(res.Get(0, "chancount"));
- }
- catch (const SQLException &ex)
- {
- Log(LOG_DEBUG) << ex.GetReason();
- }
- catch (const ConvertException &) { }
- }
-};
-
class ChanInfoUpdater : public SQLInterface, public SQLCache
{
public:
@@ -242,7 +205,6 @@ class MySQLLiveModule : public Module
service_reference<SQLProvider> SQL;
service_reference<AsynchCommandsService> ACS;
- BotInfoUpdater botinfoupdater;
ChanInfoUpdater chaninfoupdater;
NickInfoUpdater nickinfoupdater;
NickCoreUpdater nickcoreupdater;
@@ -280,53 +242,20 @@ class MySQLLiveModule : public Module
public:
MySQLLiveModule(const Anope::string &modname, const Anope::string &creator) :
- Module(modname, creator), SQL("mysql/main"), ACS("asynch_commands"), botinfoupdater(this),
+ Module(modname, creator), SQL("mysql/main"), ACS("asynch_commands"),
chaninfoupdater(this), nickinfoupdater(this), nickcoreupdater(this)
{
- Implementation i[] = { I_OnFindBot, I_OnFindChan, I_OnFindNick, I_OnFindCore, I_OnPreShutdown };
- ModuleManager::Attach(i, this, 5);
+ Implementation i[] = { I_OnFindChan, I_OnFindNick, I_OnFindCore, I_OnPreShutdown };
+ ModuleManager::Attach(i, this, 4);
}
void OnPreShutdown()
{
- Implementation i[] = { I_OnFindBot, I_OnFindChan, I_OnFindNick, I_OnFindCore };
- for (size_t j = 0; j < 4; ++j)
+ Implementation i[] = { I_OnFindChan, I_OnFindNick, I_OnFindCore };
+ for (size_t j = 0; j < 3; ++j)
ModuleManager::Detach(i[j], this);
}
- void OnFindBot(const Anope::string &nick)
- {
- if (botinfoupdater.Check(nick))
- return;
-
- try
- {
- Anope::string query = "SELECT * FROM `anope_bs_core` WHERE `nick` = '" + this->Escape(nick) + "'";
- CommandMutex *current_command = this->CurrentCommand();
- if (current_command)
- {
- current_command->Unlock();
- try
- {
- SQLResult res = this->RunQuery(query);
- current_command->Lock();
- BotInfoUpdater::Process(res);
- }
- catch (const SQLException &ex)
- {
- current_command->Lock();
- throw;
- }
- }
- else
- this->RunQuery(&botinfoupdater, query);
- }
- catch (const SQLException &ex)
- {
- Log(LOG_DEBUG) << "OnBotChan: " << ex.GetReason();
- }
- }
-
void OnFindChan(const Anope::string &chname)
{
if (chaninfoupdater.Check(chname))
diff --git a/modules/extra/m_async_commands.cpp b/modules/extra/m_async_commands.cpp
index 4f251431c..b97be4788 100644
--- a/modules/extra/m_async_commands.cpp
+++ b/modules/extra/m_async_commands.cpp
@@ -1,6 +1,7 @@
#include "module.h"
#include "async_commands.h"
+static bool ignore_pre_command = false;
static Pipe *me;
static CommandMutex *current_command = NULL;
static std::list<CommandMutex *> commands;
@@ -9,8 +10,8 @@ static Mutex main_mutex;
class AsynchCommandMutex : public CommandMutex
{
- bool destroy;
public:
+ bool destroy;
bool started;
AsynchCommandMutex(CommandSource &s, Command *c, const std::vector<Anope::string> &p) : CommandMutex(s, c, p), destroy(false), started(false)
@@ -35,6 +36,12 @@ class AsynchCommandMutex : public CommandMutex
User *u = this->source.u;
BotInfo *bi = this->source.owner;
+
+ ignore_pre_command = true;
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, command, params));
+ if (MOD_RESULT == EVENT_STOP)
+ return;
if (!command->permission.empty() && !u->Account()->HasCommand(command->permission))
{
@@ -44,13 +51,11 @@ class AsynchCommandMutex : public CommandMutex
else
{
CommandReturn ret = command->Execute(source, params);
-
- if (ret == MOD_CONT)
+ if (ret != MOD_STOP)
{
FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, command, params));
+ source.DoReply();
}
-
- source.DoReply();
}
main_mutex.Unlock();
@@ -59,13 +64,17 @@ class AsynchCommandMutex : public CommandMutex
void Lock()
{
if (this->destroy)
- {
this->Exit();
- }
this->processing = true;
me->Notify();
this->mutex.Lock();
+
+ if (this->destroy)
+ {
+ this->Unlock();
+ this->Exit();
+ }
}
void Unlock()
@@ -111,6 +120,8 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe
Implementation i[] = { I_OnObjectDestroy, I_OnPreCommand };
ModuleManager::Attach(i, this, 2);
+ ModuleManager::SetPriority(this, PRIORITY_FIRST);
+
ModuleManager::RegisterService(this);
}
@@ -132,12 +143,21 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe
EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> &params)
{
- AsynchCommandMutex *cm = new AsynchCommandMutex(source, command, params);
+ if (ignore_pre_command)
+ {
+ ignore_pre_command = false;
+ return EVENT_CONTINUE;
+ }
+ else if (current_command)
+ return EVENT_CONTINUE;
+
+ CommandSource source_copy = source;
+ AsynchCommandMutex *cm = new AsynchCommandMutex(source_copy, command, params);
try
{
// Give processing to the command thread
- Log(LOG_DEBUG_2) << "Waiting for command thread " << cm->command->name << " from " << source.u->nick;
+ Log(LOG_DEBUG_2) << "Waiting for command thread " << cm->command->name << " from " << source_copy.u->nick;
current_command = cm;
threadEngine.Start(cm);
main_mutex.Lock();
@@ -163,11 +183,20 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe
// Thread engine will pick this up later
if (cm->GetExitState() || !cm->processing)
continue;
+ else if (cm->destroy)
+ {
+ if (cm->started)
+ cm->mutex.Unlock();
+ else
+ delete cm;
+ continue;
+ }
Log(LOG_DEBUG_2) << "Waiting for command thread " << cm->command->name << " from " << cm->source.u->nick;
current_command = cm;
// Unlock to give processing back to the command thread
+ PushLanguage("anope", cm->source.u->Account() ? cm->source.u->Account()->language : "");
if (!cm->started)
{
try
@@ -177,6 +206,7 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe
catch (const CoreException &)
{
delete cm;
+ PopLanguage();
continue;
}
}
@@ -184,6 +214,7 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe
cm->mutex.Unlock();
// Relock to regain processing once the command thread hangs for any reason
main_mutex.Lock();
+ PopLanguage();
current_command = NULL;
diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp
index b33e9555e..39c4cca19 100644
--- a/modules/extra/m_xmlrpc_main.cpp
+++ b/modules/extra/m_xmlrpc_main.cpp
@@ -89,7 +89,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
else
request->reply("online", "yes");
- mod_run_cmd(bi, *u, command, false);
+ mod_run_cmd(bi, *u, NULL, command);
if (created && u)
{
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index c6dafc81a..a8868817c 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -529,21 +529,21 @@ class InspircdIRCdMessage : public IRCdMessage
send_cmd("", "ERROR :m_globops is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_globops module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_servicesmod)
{
send_cmd("", "ERROR :m_services is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_services module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_hidechansmod)
{
send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 958709b06..d2ae35c9f 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -644,21 +644,21 @@ class Inspircd12IRCdMessage : public InspircdIRCdMessage
send_cmd("", "ERROR :m_globops is not loaded. This is required by Anope");
quitmsg = "Remote server does not have the m_globops module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_servicesmod)
{
send_cmd("", "ERROR :m_services_account.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_hidechansmod)
{
send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index e1e339635..a0fd55481 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -360,7 +360,7 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage
send_cmd("", "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START");
quitmsg = "Protocol mismatch, no or invalid protocol version given in CAPAB START";
quitting = true;
- return MOD_STOP;
+ return false;
}
/* reset CAPAB */
@@ -627,14 +627,14 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage
send_cmd("", "ERROR :m_services_account.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!ModeManager::FindUserModeByName(UMODE_PRIV))
{
send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope");
quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
quitting = true;
- return MOD_STOP;
+ return false;
}
if (!has_svsholdmod)
ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");