]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
ReadFlag, oops
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index 63bfee39e067b925220e13fd43bd6ffbebba430b..4a37b1b04cffaef2400178d00c148da209edd541 100644 (file)
  * ---------------------------------------------------
  */
 
-#include <string>
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include <stdexcept>
-#include "inspircd_config.h"
 #include "socket.h"
 #include "configreader.h"
 #include "inspstring.h"
@@ -362,6 +356,8 @@ bool InspSocket::FlushWriteBuffer()
                                this->Instance->Log(DEBUG,"Write error on socket: %s",strerror(errno));
                                this->OnError(I_ERR_WRITE);
                                this->state = I_ERROR;
+                               this->Instance->SE->DelFd(this);
+                               this->Close();
                                return true;
                        }
                }
@@ -373,7 +369,7 @@ void SocketTimeout::Tick(time_t now)
 {
        if (ServerInstance->SE->GetRef(this->sfd) != this->sock)
        {
-               ServerInstance->Log(DEBUG,"No FD or socket ref");
+               ServerInstance->Log(DEBUG,"Our socket has been deleted before the timeout was reached.");
                return;
        }
 
@@ -387,8 +383,12 @@ void SocketTimeout::Tick(time_t now)
                this->sock->OnTimeout();
                this->sock->OnError(I_ERR_TIMEOUT);
                this->sock->timeout = true;
-               this->sock->state = I_ERROR;
                ServerInstance->SE->DelFd(this->sock);
+               /* NOTE: We must set this AFTER DelFd, as we added
+                * this socket whilst writeable. This means that we
+                * must DELETE the socket whilst writeable too!
+                */
+               this->sock->state = I_ERROR;
                this->sock->Close();
                delete this->sock;
                return;