summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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());