]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket1.cpp
Make classbase and refcountbase uncopyable; expand comments on their indended uses
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket1.cpp
index 2c845bbd4bf6384d9c89437a90e2476b62a8e622..f6f237529cf45bbb3baaeb44a2daa812c7b20579 100644 (file)
@@ -38,9 +38,30 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, const std::string& shost, in
        capab_phase = 0;
        proto_version = 0;
        LinkState = CONNECTING;
+       if (!hook.empty())
+       {
+               modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
+               if (ml)
+               {
+                       for(modulelist::iterator i = ml->begin(); i != ml->end(); ++i)
+                       {
+                               std::string name = (**i).ModuleSourceFile;
+                               int a = name.rfind('_');
+                               int b = name.rfind('.');
+                               name = name.substr(a+1, b-a-1);
+                               if (name == hook)
+                               {
+                                       AddIOHook(*i);
+                                       goto found;
+                               }
+                       }
+               }
+               SetError("Could not find hook '" + hook + "' for connection to " + ServerName);
+               return;
+       }
+found:
        DoConnect(shost, iport, maxtime, bindto);
        Utils->timeoutlist[this] = std::pair<std::string, int>(ServerName, maxtime);
-       // TODO AddIOHook using the given hook
        SendCapabilities(1);
 }
 
@@ -82,9 +103,11 @@ void TreeSocket::CleanNegotiationInfo()
        OutboundPass.clear();
 }
 
-bool TreeSocket::cull()
+CullResult TreeSocket::cull()
 {
        Utils->timeoutlist.erase(this);
+       if (myautoconnect)
+               Utils->Creator->ConnectServer(myautoconnect, false);
        return this->BufferedSocket::cull();
 }
 
@@ -129,7 +152,6 @@ void TreeSocket::OnError(BufferedSocketError e)
        {
                case I_ERR_CONNECT:
                        ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Connection to \002%s\002 refused", myhost.c_str());
-                       Utils->Creator->ConnectServer(myautoconnect);
                break;
                case I_ERR_SOCKET:
                        ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Could not create socket (%s)", strerror(errno));