]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix bug found by peavey, which much frustrated him and w00t. He leiks mudkipz. Also...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 21 Apr 2008 23:16:07 +0000 (23:16 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 21 Apr 2008 23:16:07 +0000 (23:16 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9575 e03df62e-2008-0410-955e-edbf42e46eb7

src/snomasks.cpp
src/users.cpp

index 2ab473b4506594424e0ed551f650daa6acc1c69f..eaa7bd1f12e713daea1c444c277339120cd496b6 100644 (file)
@@ -158,7 +158,7 @@ void Snomask::Flush()
        {
                // XXX this is a bit ugly.
                std::string sno;
-               sno[0] = MySnomask;
+               sno += MySnomask;
 
                ServerInstance->PI->SendSNONotice(sno, this->Description + ": " + this->LastMessage);
                if (Count > 1)
index 108ce138559dfb4b6a0d9e76fb000a824d7d9ed6..9276f7d93393823c33bdd59f808cfd89efe99de2 100644 (file)
 #include "bancache.h"
 #include "commands/cmd_whowas.h"
 
+/* XXX: Used for speeding up WriteCommon operations */
+unsigned long uniq_id = 1;
+
 static unsigned long* already_sent = NULL;
 
 
 void InitializeAlreadySent(SocketEngine* SE)
 {
        already_sent = new unsigned long[SE->GetMaxFds()];
-       memset(already_sent, 0, sizeof(already_sent));
+       memset(already_sent, 0, SE->GetMaxFds() * sizeof(long));
+       printf("\n\nInit Already Sent, uniq id = %lu\n\n", uniq_id);
 }
 
-/* XXX: Used for speeding up WriteCommon operations */
-unsigned long uniq_id = 1;
 
 std::string User::ProcessNoticeMasks(const char *sm)
 {
@@ -620,17 +622,24 @@ 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()
 {
+       printf("\nFlush buffer on %d\n", this->GetFd());
        try
        {
+               printf("1\n");
                if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
                {
+                       printf("Write error set, clear sendq: %s\n", this->GetWriteError());
                        sendq.clear();
                }
+               printf("2 sendq len = %u fd = %d\n", sendq.length(), this->fd);
                if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
                {
+                       printf("3\n");
                        int old_sendq_length = sendq.length();
                        int n_sent = ServerInstance->SE->Send(this, this->sendq.data(), this->sendq.length(), 0);
 
+                       printf("\nWrote %d\n", n_sent);
+
                        if (n_sent == -1)
                        {
                                if (errno == EAGAIN)
@@ -645,6 +654,7 @@ void User::FlushWriteBuf()
                                        /* Fatal error, set write error and bail
                                         */
                                        this->SetWriteError(errno ? strerror(errno) : "EOF from client");
+                                       printf("\nError on %d\n", this->GetFd());
                                        return;
                                }
                        }
@@ -667,6 +677,8 @@ void User::FlushWriteBuf()
                ServerInstance->Logs->Log("USERS", DEBUG,"Exception in User::FlushWriteBuf()");
        }
 
+       printf("end flush\n");
+
        if (this->sendq.empty())
        {
                FOREACH_MOD(I_OnBufferFlushed,OnBufferFlushed(this));
@@ -675,6 +687,7 @@ void User::FlushWriteBuf()
 
 void User::SetWriteError(const std::string &error)
 {
+       printf("SET WRITE ERROR: %s\n", error.c_str());
        // don't try to set the error twice, its already set take the first string.
        if (this->WriteError.empty())
                this->WriteError = error;
@@ -1137,6 +1150,7 @@ const char* User::GetIPString(bool translate4in6)
  */
 void User::Write(std::string text)
 {
+       printf("Write Error is %s\n", *(GetWriteError()) ? "set" : "unset");
        if (!ServerInstance->SE->BoundsCheckFd(this))
                return;