From e2af2347fc035d702e45f12e772223a8d578410d Mon Sep 17 00:00:00 2001 From: danieldg Date: Mon, 21 Sep 2009 13:26:31 +0000 Subject: Create StreamSocket for IO hooking implementation Fixes the SSL SendQ bug Removes duplicate code between User and BufferedSocket Simplify SSL module API Simplify EventHandler API (Readable/Writeable moved to SE) Add hook for culled objects to invoke callbacks prior to destructor Replace SocketCull with GlobalCull now that sockets can close themselves Shorten common case of user read/parse/write path: User::Write is now zero-copy up to syscall/SSL invocation User::Read has only two copy/scan passes from read() to ProcessCommand git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11752 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'src/command_parse.cpp') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 92d4b8c24..cbf6a1005 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -226,23 +226,6 @@ CmdResult CommandParser::CallHandler(const std::string &commandname, const std:: return CMD_INVALID; } -void CommandParser::DoLines(User* current, bool one_only) -{ - while (current->BufferIsReady()) - { - // use GetBuffer to copy single lines into the sanitized string - std::string single_line = current->GetBuffer(); - current->bytes_in += single_line.length(); - current->cmds_in++; - if (single_line.length() > MAXBUF - 2) // MAXBUF is 514 to allow for neccessary line terminators - single_line.resize(MAXBUF - 2); // So to trim to 512 here, we use MAXBUF - 2 - - // ProcessBuffer returns false if the user has gone over penalty - if (!ServerInstance->Parser->ProcessBuffer(single_line, current) || one_only) - break; - } -} - bool CommandParser::ProcessCommand(User *user, std::string &cmd) { std::vector command_p; @@ -435,23 +418,12 @@ void CommandParser::RemoveCommand(Commandtable::iterator safei, Module* source) bool CommandParser::ProcessBuffer(std::string &buffer,User *user) { - std::string::size_type a; - - if (!user) + if (!user || buffer.empty()) return true; - while ((a = buffer.rfind("\n")) != std::string::npos) - buffer.erase(a); - while ((a = buffer.rfind("\r")) != std::string::npos) - buffer.erase(a); - - if (buffer.length()) - { - ServerInstance->Logs->Log("USERINPUT", DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick.c_str(), buffer.c_str()); - return this->ProcessCommand(user,buffer); - } - - return true; + ServerInstance->Logs->Log("USERINPUT", DEBUG, "C[%d] I :%s %s", + user->GetFd(), user->nick.c_str(), buffer.c_str()); + return ProcessCommand(user,buffer); } bool CommandParser::CreateCommand(Command *f) -- cgit v1.2.3