diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-24 17:10:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-24 17:10:19 +0000 |
commit | 9067d816e5797676004ae50babb262dc4ca702e1 (patch) | |
tree | 6ef409d1b199ee7c25fa6a675f4f46761e7eb243 /src/inspircd.cpp | |
parent | a0f17e57ccc1d6f7923da8eb6ba8e55d1ea61301 (diff) |
Added extra code to notify mainloop when the iterator has been mangled (e.g. by netsplit quits)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1499 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f11070d07..6ee535cd9 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -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; + } } } |