From 9067d816e5797676004ae50babb262dc4ca702e1 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 24 May 2005 17:10:19 +0000 Subject: 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 --- src/inspircd.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/inspircd.cpp') 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, irc::StrHashComp> user_hash; typedef nspace::hash_map, irc::StrHashComp> chan_hash; typedef nspace::hash_map, 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; + } } } -- cgit v1.2.3