summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-24 20:03:45 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-24 20:03:45 +0000
commit68e8a75daf6933d7ec4a3bd21cf12ed1ac880739 (patch)
treefbb0d33091f3866528b4f90607c3c10c4bc407f1
parente6649f13553bbf0b61910766827919f531c31115 (diff)
Catch exceptions in inspsocket callbacks
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11966 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspsocket.cpp74
1 files changed, 41 insertions, 33 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 7485324a2..86104c54d 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -491,44 +491,52 @@ void StreamSocket::HandleEvent(EventType et, int errornum)
if (!error.empty())
return;
BufferedSocketError errcode = I_ERR_OTHER;
- switch (et)
- {
- case EVENT_ERROR:
+ try {
+ switch (et)
{
- if (errornum == 0)
- SetError("Connection closed");
- else
- SetError(strerror(errornum));
- switch (errornum)
+ case EVENT_ERROR:
{
- case ETIMEDOUT:
- errcode = I_ERR_TIMEOUT;
- break;
- case ECONNREFUSED:
- case 0:
- errcode = I_ERR_CONNECT;
- break;
- case EADDRINUSE:
- errcode = I_ERR_BIND;
- break;
- case EPIPE:
- case EIO:
- errcode = I_ERR_WRITE;
- break;
+ if (errornum == 0)
+ SetError("Connection closed");
+ else
+ SetError(strerror(errornum));
+ switch (errornum)
+ {
+ case ETIMEDOUT:
+ errcode = I_ERR_TIMEOUT;
+ break;
+ case ECONNREFUSED:
+ case 0:
+ errcode = I_ERR_CONNECT;
+ break;
+ case EADDRINUSE:
+ errcode = I_ERR_BIND;
+ break;
+ case EPIPE:
+ case EIO:
+ errcode = I_ERR_WRITE;
+ break;
+ }
+ break;
+ }
+ case EVENT_READ:
+ {
+ DoRead();
+ break;
+ }
+ case EVENT_WRITE:
+ {
+ DoWrite();
+ break;
}
- break;
- }
- case EVENT_READ:
- {
- DoRead();
- break;
- }
- case EVENT_WRITE:
- {
- DoWrite();
- break;
}
}
+ catch (CoreException& ex)
+ {
+ ServerInstance->Logs->Log("SOCKET", ERROR, "Caught exception in socket processing on FD %d - '%s'",
+ fd, ex.GetReason());
+ SetError(ex.GetReason());
+ }
if (!error.empty())
{
ServerInstance->Logs->Log("SOCKET", DEBUG, "Error on FD %d - '%s'", fd, error.c_str());