diff options
author | Adam <Adam@anope.org> | 2012-11-23 16:56:06 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-11-23 16:56:06 -0500 |
commit | 36b1166cf6efddbc9a9abc8f00ad13bb0d4e56a9 (patch) | |
tree | a5883db9349de07b349647f467abfe05f8a2810e /src | |
parent | 0e7bd9f3ba9ff8fe634fcf7d365ea2a984655d83 (diff) |
Change the return type of ircdmessage to void now that we don't use it, add an ircd message module event, and a few more fixups
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/messages.cpp | 88 | ||||
-rw-r--r-- | src/process.cpp | 9 | ||||
-rw-r--r-- | src/socketengines/pipeengine_pipe.cpp | 6 |
4 files changed, 48 insertions, 57 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b9d58f367..2c7566e78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,7 @@ endif(WIN32) # If we have eventfd, use it if(HAVE_EVENTFD) - append_to_list(SRC_SRCS socketengines/pipeengine_eventfd.cpp) + append_to_list(SRC_SRCS socketengines/pipeengine_pipe.cpp) # Else fall back to pipe else(HAVE_EVENTFD) append_to_list(SRC_SRCS socketengines/pipeengine_pipe.cpp) diff --git a/src/messages.cpp b/src/messages.cpp index 62170e24e..f5e598945 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -23,13 +23,12 @@ using namespace Message; -bool Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { FOREACH_MOD(I_OnUserAway, OnUserAway(source.GetUser(), params.empty() ? "" : params[0])); - return true; } -bool Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { if (params.size() == 1) { @@ -41,19 +40,16 @@ bool Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) else for (unsigned i = 0; i < params.size(); ++i) Servers::Capab.insert(params[i]); - return true; } -bool Error::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Error::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Log(LOG_TERMINAL) << "ERROR: " << params[0]; Anope::QuitReason = "Received ERROR from uplink: " + params[0]; Anope::Quitting = true; - - return true; } -bool Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *user = source.GetUser(); const Anope::string &channels = params[0]; @@ -85,8 +81,6 @@ bool Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) Channel *chan = Channel::Find(channel); SJoin(source, channel, chan ? chan->creation_time : Anope::CurTime, "", users); } - - return true; } void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list<SJoinUser> &users) @@ -154,7 +148,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co } } -bool Kick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Kick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &channel = params[0]; const Anope::string &users = params[1]; @@ -162,23 +156,22 @@ bool Kick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) Channel *c = Channel::Find(channel); if (!c) - return true; + return; Anope::string user; commasepstream sep(users); while (sep.GetToken(user)) c->KickInternal(source, user, reason); - return true; } -bool Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = User::Find(params[0]); BotInfo *bi; if (!u) - return true; + return; /* Recover if someone kills us. */ if (u->server == Me && (bi = dynamic_cast<BotInfo *>(u))) @@ -189,7 +182,7 @@ bool Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Anope::QuitReason = "Kill loop detected. Are Services U:Lined?"; Anope::Quitting = true; - return true; + return; } last_time = Anope::CurTime; @@ -202,11 +195,9 @@ bool Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) } else u->KillInternal(source.GetSource(), params[1]); - - return true; } -bool Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { if (IRCD->IsChannelValid(params[0])) { @@ -222,16 +213,14 @@ bool Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> if (u) u->SetModesInternal("%s", params[1].c_str()); } - - return true; } /* XXX We should cache the file somewhere not open/read/close it on every request */ -bool MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Server *s = Server::Find(params[0]); if (s != Me) - return true; + return; FILE *f = fopen(Config->MOTDFilename.c_str(), "r"); if (f) @@ -248,11 +237,9 @@ bool MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) } else IRCD->SendNumeric(422, source.GetSource(), ":- MOTD file not found! Please contact your IRC administrator."); - - return true; } -bool Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); const Anope::string &reason = params.size() > 1 ? params[1] : ""; @@ -273,17 +260,14 @@ bool Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) c->DeleteUser(u); FOREACH_MOD(I_OnPartChannel, OnPartChannel(u, c, ChannelName, !reason.empty() ? reason : "")); } - - return true; } -bool Ping::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Ping::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { IRCD->SendPong(params.size() > 1 ? params[1] : Me->GetSID(), params[0]); - return true; } -bool Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &receiver = params[0]; Anope::string message = params[1]; @@ -309,16 +293,16 @@ bool Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m Anope::string servername(receiver.begin() + s + 1, receiver.end()); botname = botname.substr(0, s); if (!servername.equals_ci(Config->ServerName)) - return true; + return; } else if (Config->UseStrictPrivMsg) { const BotInfo *bi = BotInfo::Find(receiver); if (!bi) - return true; + return; Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick; u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Config->ServerName.c_str(), bi->nick.c_str()); - return true; + return; } BotInfo *bi = BotInfo::Find(botname); @@ -328,7 +312,7 @@ bool Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m EventReturn MOD_RESULT; FOREACH_RESULT(I_OnBotPrivmsg, OnBotPrivmsg(u, bi, message)); if (MOD_RESULT == EVENT_STOP) - return true; + return; if (message[0] == '\1' && message[message.length() - 1] == '\1') { @@ -344,17 +328,17 @@ bool Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str()); } - return true; + return; } bi->OnMessage(u, message); } } - return true; + return; } -bool Quit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Quit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &reason = params[0]; User *user = source.GetUser(); @@ -370,27 +354,27 @@ bool Quit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) FOREACH_MOD(I_OnUserQuit, OnUserQuit(user, reason)); delete user; - return true; + return; } -bool SQuit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void SQuit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Server *s = Server::Find(params[0]); if (!s) { Log() << "SQUIT for nonexistent server " << params[0]; - return true; + return; } FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); s->Delete(s->GetName() + " " + s->GetUplink()->GetName()); - return true; + return; } -bool Stats::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Stats::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); @@ -438,10 +422,10 @@ bool Stats::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); } - return true; + return; } -bool Time::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Time::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { time_t t; time(&t); @@ -449,26 +433,26 @@ bool Time::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) char buf[64]; strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); IRCD->SendNumeric(391, source.GetSource(), "%s :%s", Config->ServerName.c_str(), buf); - return true; + return; } -bool Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Channel *c = Channel::Find(params[0]); if (c) c->ChangeTopicInternal(source.GetSource(), params[1], Anope::CurTime); - return true; + return; } -bool Version::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Version::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str()); - return true; + return; } -bool Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +void Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = User::Find(params[0]); @@ -486,6 +470,6 @@ bool Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) else IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str()); - return true; + return; } diff --git a/src/process.cpp b/src/process.cpp index cc2b32a27..2b94c1e7a 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -75,8 +75,13 @@ void Anope::Process(const Anope::string &buffer) } static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; + + MessageSource src(source); - // event + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnMessage, OnMessage(src, command, params)); + if (MOD_RESULT == EVENT_STOP) + return; ServiceReference<IRCDMessage> m("IRCDMessage", proto_name + "/" + command.lower()); if (!m) @@ -85,8 +90,6 @@ void Anope::Process(const Anope::string &buffer) return; } - MessageSource src(source); - if (m->HasFlag(IRCDMESSAGE_SOFT_LIMIT) ? (params.size() < m->GetParamCount()) : (params.size() != m->GetParamCount())) Log(LOG_DEBUG) << "invalid parameters for " << command << ": " << params.size() << " != " << m->GetParamCount(); else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser()) diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp index b05c50582..d56ffef55 100644 --- a/src/socketengines/pipeengine_pipe.cpp +++ b/src/socketengines/pipeengine_pipe.cpp @@ -27,7 +27,11 @@ Pipe::Pipe() : Socket(-1), write_pipe(-1) flags = fcntl(fds[1], F_GETFL, 0); fcntl(fds[1], F_SETFL, flags | O_NONBLOCK); - this->~Pipe(); + SocketEngine::Change(this, false, SF_READABLE); + SocketEngine::Change(this, false, SF_WRITABLE); + anope_close(this->sock); + this->io->Destroy(); + SocketEngine::Sockets.erase(this->sock); this->sock = fds[0]; this->write_pipe = fds[1]; |