]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added extra code to notify mainloop when the iterator has been mangled (e.g. by netsp...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 May 2005 17:10:19 +0000 (17:10 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 May 2005 17:10:19 +0000 (17:10 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1499 e03df62e-2008-0410-955e-edbf42e46eb7

src/connection.cpp
src/inspircd.cpp
src/servers.cpp

index f246a2dac7800e1809d97b0fddcfff1f2d3c62c7..30a961e96f4b2ef5ba0318b8a29d303100a609b0 100644 (file)
@@ -32,7 +32,7 @@ using namespace std;
 #include "inspstring.h"
 #include "helperfuncs.h"
 
-
+extern bool has_been_netsplit;
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 
@@ -200,6 +200,7 @@ bool ircd_connector::CheckPing()
                                this->CloseConnection();
                                this->SetState(STATE_DISCONNECTED);
                                WriteOpers("*** Ping timeout on link to %s (more routes may remain)",this->GetServerName().c_str());
+                               has_been_netsplit = true;
                                return false;
                        }
                }
index f11070d0726c413689bf0445c960d7275c5ef147..6ee535cd94910607833c3f0a5b4eaa58723f1713 100644 (file)
@@ -119,6 +119,8 @@ int kq, lkq, skq;
 int ep, lep, sep;
 #endif
 
+bool has_been_netsplit = false;
+
 typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
 typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
 typedef nspace::hash_map<in_addr,string*, nspace::hash<in_addr>, irc::InAddr_HashComp> address_cache;
@@ -1742,6 +1744,7 @@ void DoSplitEveryone()
                        }
                }
        }
+       has_been_netsplit = true;
 }
 
 
@@ -2341,6 +2344,7 @@ void DoSplit(const char* params)
                        }
                }
        }
+       has_been_netsplit = true;
 }
 
 // removes a server. Will NOT remove its users!
@@ -2940,6 +2944,7 @@ int InspIRCd(char** argv, int argc)
                        msgs.clear();
                        while ((me[x]) && (me[x]->RecvPacket(msgs, tcp_host, sums))) // returns 0 or more lines (can be multiple lines!)
                        {
+                               has_been_netsplit = false;
                                for (int ctr = 0; ctr < msgs.size(); ctr++)
                                {
                                        strlcpy(tcp_msg,msgs[ctr].c_str(),MAXBUF);
@@ -2974,8 +2979,14 @@ int InspIRCd(char** argv, int argc)
                                                goto label;
                                        }
                                }
-                                       sums.clear();   // we're done, clear the list for the next operation
-                                       msgs.clear();
+                                       sums.clear();   // we're done, clear the list for the next operation
+                               msgs.clear();
+                               // theres been a netsplit, its unsafe to mess with the iterators!
+                               if (has_been_netsplit)
+                               {
+                                       log(DEBUG,"Iterator modified, bailing");
+                                       goto label;
+                               }
                        }
                }
        
index ff5f40a68ed587ac2e1c65af73b00a6cf323c4c3..a791d3557790318a1c378287d8b51be85684ebb1 100644 (file)
@@ -36,8 +36,11 @@ using namespace std;
 
 extern time_t TIME;
 extern int MaxConn;
+
 extern serverrec* me[32];
 
+extern bool has_been_netsplit;
+
 std::deque<std::string> xsums;
 
 serverrec::serverrec()
@@ -308,6 +311,7 @@ void serverrec::FlushWriteBuffers()
                                        WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
                                        DoSplit(this->connectors[i].GetServerName().c_str());
                                }
+                               has_been_netsplit = true;
                        }
                }
                 if (this->connectors[i].HasBufferedOutput())
@@ -323,6 +327,7 @@ void serverrec::FlushWriteBuffers()
                                         WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
                                         DoSplit(this->connectors[i].GetServerName().c_str());
                                 }
+                               has_been_netsplit = true;
                        }
                 }
        }
@@ -457,6 +462,7 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
                                                WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
                                                DoSplit(this->connectors[i].GetServerName().c_str());
                                        }
+                                       has_been_netsplit = true;
                                 }
                         }
                         int pushed = 0;
@@ -472,6 +478,7 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
                                                WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
                                                DoSplit(this->connectors[i].GetServerName().c_str());
                                        }
+                                       has_been_netsplit = true;
                                }
                                 if (this->connectors[i].BufferIsComplete())
                                 {