From 9c9968229fd0cc3ae346369772b41c9dbd857873 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 1 May 2007 20:18:10 +0000 Subject: Much more detailed logging of lowlevel socket errors to the +l snomask git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6856 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspsocket.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/inspsocket.cpp') diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index cdc0dc26f..3face10f6 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -119,10 +119,10 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool if (!ipvalid) { this->Instance->Log(DEBUG,"BUG: Hostname passed to InspSocket, rather than an IP address!"); + this->OnError(I_ERR_CONNECT); this->Close(); this->fd = -1; this->state = I_ERROR; - this->OnError(I_ERR_RESOLVE); return; } else @@ -131,10 +131,10 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool timeout_val = maxtime; if (!this->DoConnect()) { + this->OnError(I_ERR_CONNECT); this->Close(); this->fd = -1; this->state = I_ERROR; - this->OnError(I_ERR_CONNECT); return; } } @@ -715,6 +715,23 @@ void InspSocket::HandleEvent(EventType et, int errornum) switch (et) { case EVENT_ERROR: + switch (errornum) + { + case ETIMEDOUT: + this->OnError(I_ERR_TIMEOUT); + break; + case ECONNREFUSED: + case 0: + this->OnError(this->state == I_CONNECTING ? I_ERR_CONNECT : I_ERR_WRITE); + break; + case EADDRINUSE: + this->OnError(I_ERR_BIND); + break; + case EPIPE: + case EIO: + this->OnError(I_ERR_WRITE); + break; + } if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end()) this->Instance->SocketCull[this] = this; return; -- cgit v1.2.3