summaryrefslogtreecommitdiff
path: root/src/inspsocket.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-26 16:51:41 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-26 16:51:41 +0000
commit37a53f1ac69315f1915aae67a447fb7b813e8217 (patch)
tree57c0367cce15e2f81fcab530f35bf343505cfeb8 /src/inspsocket.cpp
parent225636f9d7aebe4556d1435fd6db04765f9a25cd (diff)
Make error reporting work properly, it seemed to loose errors.
First change: Add a culling list of inspsockets waiting to be closed, so the close() is less likely to be called before the buffer is entirely empty. This seems to work well on my LAN. Second change: Add a SendError() method, rather than WriteLine("ERROR : ..."). This can be used to effect by also echoing out "Sent ERROR to %s: ..." onto the +l snomask meaning at least one end will always see the error even if the ERROR command is lost due to latency or design of the transport (e.g. ssl which may be writing during a read event etc) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6844 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspsocket.cpp')
-rw-r--r--src/inspsocket.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 5641ba6ef..3c30fd6e8 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -573,14 +573,16 @@ void SocketTimeout::Tick(time_t now)
this->sock->OnTimeout();
this->sock->OnError(I_ERR_TIMEOUT);
this->sock->timeout = true;
- 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;
+
+ if (ServerInstance->SocketCull.find(this->sock) == ServerInstance->SocketCull.end())
+ ServerInstance->SocketCull[this->sock] = this->sock;
+
return;
}
else
@@ -717,17 +719,15 @@ void InspSocket::HandleEvent(EventType et, int errornum)
switch (et)
{
case EVENT_ERROR:
- this->Instance->SE->DelFd(this);
- this->Close();
- delete this;
+ if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
+ this->Instance->SocketCull[this] = this;
return;
break;
case EVENT_READ:
if (!this->Poll())
{
- this->Instance->SE->DelFd(this);
- this->Close();
- delete this;
+ if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
+ this->Instance->SocketCull[this] = this;
return;
}
break;
@@ -737,9 +737,8 @@ void InspSocket::HandleEvent(EventType et, int errornum)
this->WaitingForWriteEvent = false;
if (!this->OnWriteReady())
{
- this->Instance->SE->DelFd(this);
- this->Close();
- delete this;
+ if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
+ this->Instance->SocketCull[this] = this;
return;
}
}
@@ -758,9 +757,8 @@ void InspSocket::HandleEvent(EventType et, int errornum)
{
if (this->FlushWriteBuffer())
{
- this->Instance->SE->DelFd(this);
- this->Close();
- delete this;
+ if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
+ this->Instance->SocketCull[this] = this;
return;
}
}