summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp22
-rw-r--r--src/sockets.cpp7
2 files changed, 19 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0c1db63ea..a33f1dff4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -96,7 +96,15 @@ class ReconnectTimer : public Timer
void Tick(time_t)
{
- Connect();
+ try
+ {
+ Connect();
+ }
+ catch (const SocketException &ex)
+ {
+ quitmsg = ex.GetReason();
+ quitting = true;
+ }
}
};
@@ -343,13 +351,9 @@ int main(int ac, char **av, char **envp)
}
catch (const SocketException &ex)
{
- Log() << ex.GetReason();
- ModuleManager::UnloadAll();
- SocketEngine::Shutdown();
- for (Module *m; (m = ModuleManager::FindFirstOf(PROTOCOL)) != NULL;)
- ModuleManager::UnloadModule(m, NULL);
- ModuleManager::CleanupRuntimeDirectory();
- return -1;
+ quitmsg = ex.GetReason();
+ quitting = true;
+ return_code = -1;
}
started = true;
@@ -415,5 +419,5 @@ int main(int ac, char **av, char **envp)
return_code = -1;
}
- return 0;
+ return return_code;
}
diff --git a/src/sockets.cpp b/src/sockets.cpp
index 122d6b646..e95c9f7a9 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -324,7 +324,7 @@ void SocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int por
if (c == -1)
{
if (Anope::LastErrorCode() != EINPROGRESS)
- throw SocketException("Error connecting to server: " + Anope::LastError());
+ s->OnError(Anope::LastError());
else
SocketEngine::MarkWritable(s);
}
@@ -718,6 +718,11 @@ bool ConnectionSocket::ProcessWrite()
*/
void ConnectionSocket::ProcessError()
{
+ int optval = 0;
+ socklen_t optlen = sizeof(optval);
+ getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen);
+ errno = optval;
+ this->OnError(optval ? Anope::LastError() : "");
}
/** Called on a successful connect