]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix compile. Also remove write error stuff, as that was used prior to the goodness...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 19 Jul 2008 19:17:15 +0000 (19:17 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 19 Jul 2008 19:17:15 +0000 (19:17 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10042 e03df62e-2008-0410-955e-edbf42e46eb7

include/users.h
src/cull_list.cpp
src/inspircd.cpp
src/users.cpp

index b500235338b32fd88c890d8b53789b5f06735466..39abc63095ad426e9735243ba766094d8a82f9fc 100644 (file)
@@ -447,6 +447,10 @@ class CoreExport User : public connection
         */
        std::string cached_fullrealhost;
 
+       /** Set by GetIPString() to avoid constantly re-grabbing IP via sockets voodoo.
+        */
+       std::string cachedip;
+
        /** When we erase the user (in the destructor),
         * we call this method to subtract one from all
         * mode characters this user is making use of.
@@ -624,10 +628,6 @@ class CoreExport User : public connection
         * GetIPString/GetPort to obtain its values.
         */
        sockaddr* ip;
-       
-       /** Set by GetIPString() to avoid constantly re-grabbing IP via sockets voodoo.
-        */
-       std::string cachedip;
 
        /** Initialize the clients sockaddr
         * @param protocol_family The protocol family of the IP address, AF_INET or AF_INET6
@@ -660,10 +660,6 @@ class CoreExport User : public connection
         */
        const char *GetCIDRMask(int range);
 
-       /* Write error string
-        */
-       std::string WriteError;
-
        /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
         */
        bool exempt;
@@ -829,24 +825,9 @@ class CoreExport User : public connection
         */
        std::string GetBuffer();
 
-       /** Sets the write error for a connection. This is done because the actual disconnect
-        * of a client may occur at an inopportune time such as half way through /LIST output.
-        * The WriteErrors of clients are checked at a more ideal time (in the mainloop) and
-        * errored clients purged.
-        * @param error The error string to set.
-        */
-       void SetWriteError(const std::string &error);
-
-       /** Returns the write error which last occured on this connection or an empty string
-        * if none occured.
-        * @return The error string which has occured for this user
-        */
-       const char* GetWriteError();
-
        /** Adds to the user's write buffer.
         * You may add any amount of text up to this users sendq value, if you exceed the
-        * sendq value, SetWriteError() will be called to set the users error string to
-        * "SendQ exceeded", and further buffer adds will be dropped.
+        * sendq value, the user will be removed, and further buffer adds will be dropped.
         * @param data The data to add to the write buffer
         */
        void AddWriteBuf(const std::string &data);
index a7f8d3316c6375d0ab396679fbb47632cbe54150..5c7eb7b4258855ebeef7f3c18e4feffbf65d9597 100644 (file)
@@ -63,7 +63,7 @@ int CullList::Apply()
 
                if (IS_LOCAL(u))
                {
-                       if ((!u->sendq.empty()) && (!(*u->GetWriteError())))
+                       if (!u->sendq.empty())
                                u->FlushWriteBuf();
                }
 
index ac5ee4510050aa69190aa986cbcae0ec12cc8cf2..1d8ce762517fd4aed0f873c2ac2503d63efbb67b 100644 (file)
@@ -95,7 +95,7 @@ void InspIRCd::Cleanup()
        /* Close all client sockets, or the new process inherits them */
        for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
        {
-               (*i)->SetWriteError("Server shutdown");
+               this->Users->QuitUser((*i), "Server shutdown");
                (*i)->CloseSocket();
        }
 
index f7b6467548062d75184aa174cd83ee856fd2a4e9..a0ed42446e6f2087e654dc3e872f5d7b5a25be0f 100644 (file)
@@ -190,12 +190,11 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        age = ServerInstance->Time();
        Penalty = 0;
        lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
-       ChannelCount = timeout = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+       bytes_in = bytes_out = cmds_in = cmds_out = 0;
        quietquit = OverPenalty = ExemptFromPenalty = quitting = exempt = haspassed = dns_done = false;
        fd = -1;
        recvq.clear();
        sendq.clear();
-       WriteError.clear();
        res_forward = res_reverse = NULL;
        Visibility = NULL;
        ip = NULL;
@@ -560,7 +559,7 @@ bool User::AddBuffer(const std::string &a)
 
        if (this->MyClass && (recvq.length() > this->MyClass->GetRecvqMax()))
        {
-               this->SetWriteError("RecvQ exceeded");
+               ServerInstance->Users->QuitUser(this, "RecvQ exceeded");
                ServerInstance->SNO->WriteToSnoMask('A', "User %s RecvQ of %lu exceeds connect class maximum of %lu",this->nick.c_str(),(unsigned long int)recvq.length(),this->MyClass->GetRecvqMax());
                return false;
        }
@@ -620,7 +619,7 @@ std::string User::GetBuffer()
 
 void User::AddWriteBuf(const std::string &data)
 {
-       if (*this->GetWriteError())
+       if (this->quitting)
                return;
 
        if (this->MyClass && (sendq.length() + data.length() > this->MyClass->GetSendqMax()))
@@ -630,7 +629,7 @@ void User::AddWriteBuf(const std::string &data)
                 * if we dont it'll recursively  call here over and over again trying
                 * to repeatedly add the text to the sendq!
                 */
-               this->SetWriteError("SendQ exceeded");
+               ServerInstance->Users->QuitUser(this, "SendQ exceeded");
                ServerInstance->SNO->WriteToSnoMask('A', "User %s SendQ of %lu exceeds connect class maximum of %lu",this->nick.c_str(),(unsigned long int)sendq.length() + data.length(),this->MyClass->GetSendqMax());
                return;
        }
@@ -644,71 +643,53 @@ void User::AddWriteBuf(const std::string &data)
 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
 void User::FlushWriteBuf()
 {
-       try
+       if (this->fd == FD_MAGIC_NUMBER)
        {
-               if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
-               {
-                       sendq.clear();
-               }
-               if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
-               {
-                       int old_sendq_length = sendq.length();
-                       int n_sent = ServerInstance->SE->Send(this, this->sendq.data(), this->sendq.length(), 0);
+               sendq.clear();
+               return;
+       }
 
-                       if (n_sent == -1)
+       if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
+       {
+               int old_sendq_length = sendq.length();
+               int n_sent = ServerInstance->SE->Send(this, this->sendq.data(), this->sendq.length(), 0);
+
+               if (n_sent == -1)
+               {
+                       if (errno == EAGAIN)
                        {
-                               if (errno == EAGAIN)
-                               {
-                                       /* The socket buffer is full. This isnt fatal,
-                                        * try again later.
-                                        */
-                                       this->ServerInstance->SE->WantWrite(this);
-                               }
-                               else
-                               {
-                                       /* Fatal error, set write error and bail
-                                        */
-                                       this->SetWriteError(errno ? strerror(errno) : "EOF from client");
-                                       return;
-                               }
+                               /* The socket buffer is full. This isnt fatal,
+                                * try again later.
+                                */
+                               ServerInstance->SE->WantWrite(this);
                        }
                        else
                        {
-                               /* advance the queue */
-                               if (n_sent)
-                                       this->sendq = this->sendq.substr(n_sent);
-                               /* update the user's stats counters */
-                               this->bytes_out += n_sent;
-                               this->cmds_out++;
-                               if (n_sent != old_sendq_length)
-                                       this->ServerInstance->SE->WantWrite(this);
+                               /* Fatal error, set write error and bail */
+                               ServerInstance->Users->QuitUser(this, errno ? strerror(errno) : "Write error");
+                               return;
                        }
                }
+               else
+               {
+                       /* advance the queue */
+                       if (n_sent)
+                               this->sendq = this->sendq.substr(n_sent);
+                       /* update the user's stats counters */
+                       this->bytes_out += n_sent;
+                       this->cmds_out++;
+                       if (n_sent != old_sendq_length)
+                               this->ServerInstance->SE->WantWrite(this);
+               }
        }
 
-       catch (...)
-       {
-               ServerInstance->Logs->Log("USERS", DEBUG,"Exception in User::FlushWriteBuf()");
-       }
-
+       /* note: NOT else if! */
        if (this->sendq.empty())
        {
                FOREACH_MOD(I_OnBufferFlushed,OnBufferFlushed(this));
        }
 }
 
-void User::SetWriteError(const std::string &error)
-{
-       // don't try to set the error twice, its already set take the first string.
-       if (this->WriteError.empty())
-               this->WriteError = error;
-}
-
-const char* User::GetWriteError()
-{
-       return this->WriteError.c_str();
-}
-
 void User::Oper(const std::string &opertype, const std::string &opername)
 {
        char* mycmd;
@@ -882,7 +863,6 @@ void User::CheckClass()
        }
 
        this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;
-       this->timeout = ServerInstance->Time() + a->GetRegTimeout();
        this->MaxChans = a->GetMaxChans();
 }
 
@@ -1979,37 +1959,17 @@ void User::HandleEvent(EventType et, int errornum)
        if (this->quitting) // drop everything, user is due to be quit
                return;
 
-       /* WARNING: May delete this user! */
-       int thisfd = this->GetFd();
-
-       try
+       switch (et)
        {
-               switch (et)
-               {
-                       case EVENT_READ:
-                               ServerInstance->ProcessUser(this);
-                       break;
-                       case EVENT_WRITE:
-                               this->FlushWriteBuf();
-                       break;
-                       case EVENT_ERROR:
-                               /** This should be safe, but dont DARE do anything after it -- Brain */
-                               this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
-                       break;
-               }
-       }
-       catch (...)
-       {
-               ServerInstance->Logs->Log("USERS", DEBUG,"Exception in User::HandleEvent intercepted");
-       }
-
-       /* If the user has raised an error whilst being processed, quit them now we're safe to */
-       if ((ServerInstance->SE->GetRef(thisfd) == this))
-       {
-               if (!WriteError.empty())
-               {
-                       ServerInstance->Users->QuitUser(this, GetWriteError());
-               }
+               case EVENT_READ:
+                       ServerInstance->ProcessUser(this);
+               break;
+               case EVENT_WRITE:
+                       this->FlushWriteBuf();
+               break;
+               case EVENT_ERROR:
+                       ServerInstance->Users->QuitUser(this, errornum ? strerror(errornum) : "Client closed the connection");
+               break;
        }
 }