]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Change to use std::string::iterator rather than making a copy of the pointer and...
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index 1096162db45374e9416102f16020da0a44b64255..68e2c8f96aea8060ae25df558d4bbdda0a6f281e 100644 (file)
@@ -2,12 +2,9 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
@@ -265,9 +262,9 @@ void InspSocket::Close()
                        {
                                Instance->Config->GetIOHook(this)->OnRawSocketClose(this->fd);
                        }
-                       catch (ModuleException& modexcept)
+                       catch (CoreException& modexcept)
                        {
-                               Instance->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
+                               Instance->Log(DEFAULT,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
                        }
                }
                this->OnClose();
@@ -296,9 +293,9 @@ char* InspSocket::Read()
                {
                        MOD_RESULT = Instance->Config->GetIOHook(this)->OnRawSocketRead(this->fd,this->ibuf,sizeof(this->ibuf),result2);
                }
-               catch (ModuleException& modexcept)
+               catch (CoreException& modexcept)
                {
-                       Instance->Log(DEBUG,"Module exception caught: %s",modexcept.GetReason());
+                       Instance->Log(DEFAULT,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
                }
                if (MOD_RESULT < 0)
                {
@@ -367,7 +364,6 @@ bool InspSocket::FlushWriteBuffer()
                        {
                                try
                                {
-                                       Instance->Log(DEBUG,"To write: %s", outbuffer[0].c_str());
                                        int result = Instance->Config->GetIOHook(this)->OnRawSocketWrite(this->fd, outbuffer[0].c_str(), outbuffer[0].length());
                                        if (result > 0)
                                        {
@@ -391,10 +387,19 @@ bool InspSocket::FlushWriteBuffer()
                                                this->Close();
                                                return true;
                                        }
+                                       else if (result == 0)
+                                       {
+                                               this->Instance->Log(DEBUG,"Write error on socket: EOF");
+                                               this->OnError(I_ERR_WRITE);
+                                               this->state = I_ERROR;
+                                               this->Instance->SE->DelFd(this);
+                                               this->Close();
+                                               return true;
+                                       }
                                }
-                               catch (ModuleException& modexcept)
+                               catch (CoreException& modexcept)
                                {
-                                       Instance->Log(DEBUG,"Module exception caught: %s",modexcept.GetReason());
+                                       Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
                                        return true;
                                }
                        }
@@ -506,15 +511,15 @@ bool InspSocket::Poll()
                                if (!this->Instance->SE->AddFd(this))
                                        return false;
                        }
-                       if (this->IsIOHooked)
+                       if (Instance->Config->GetIOHook(this))
                        {
                                try
                                {
                                        Instance->Config->GetIOHook(this)->OnRawSocketConnect(this->fd);
                                }
-                               catch (ModuleException& modexcept)
+                               catch (CoreException& modexcept)
                                {
-                                       Instance->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
+                                       Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
                                }
                        }
                        return this->OnConnected();
@@ -539,9 +544,9 @@ bool InspSocket::Poll()
                                        Instance->Config->GetIOHook(this)->OnRawSocketAccept(incoming, insp_ntoa(client.sin_addr), this->port);
 #endif
                                }
-                               catch (ModuleException& modexcept)
+                               catch (CoreException& modexcept)
                                {
-                                       Instance->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
+                                       Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
                                }
                        }
 
@@ -632,7 +637,6 @@ void InspSocket::HandleEvent(EventType et, int errornum)
                        }
                        else
                        {
-                               Instance->Log(DEBUG,"State=%d CONNECTED=%d", this->state, I_CONNECTED);
                                if (this->FlushWriteBuffer())
                                {
                                        this->Instance->SE->DelFd(this);