]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/fjoin.cpp
Addendum to previous ping patch: NextPingTime was not being set at endburst, and...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / fjoin.cpp
index e7ce0ac54a14f4a8aac81a57f083638de0cbc423..b9bd79f18764089a708157782d14c569eb2ff2c0 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -58,8 +58,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        std::string channel = params[0];                                /* Channel name, as a string */
        time_t TS = atoi(params[1].c_str());                            /* Timestamp given to us for remote side */
        irc::tokenstream users((params.size() > 3) ? params[params.size() - 1] : "");   /* users from the user list */
-       bool apply_other_sides_umodes = true;                           /* True if we are accepting the other side's user umodes */
-       bool apply_other_sides_cmodes = true;                           /* True if we are accepting the other side's channel modes */
+       bool apply_other_sides_modes = true;                            /* True if we are accepting the other side's modes */
        Channel* chan = this->ServerInstance->FindChan(channel);                /* The channel we're sending joins to */
        bool created = !chan;                                           /* True if the channel doesnt exist here yet */
        std::string item;                                               /* One item in the list of nicks */
@@ -85,14 +84,14 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        {
                time_t ourTS = chan->age;
 
-               ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN recieved for %s, ourTS: %lu, TS: %lu, difference: %lu",
-                       chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)ourTS - (unsigned long)TS);
+               if (TS != ourTS)
+                       ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN recieved for %s, ourTS: %lu, TS: %lu, difference: %lu",
+                               chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS));
                /* If our TS is less than theirs, we dont accept their modes */
                if (ourTS < TS)
                {
                        ServerInstance->SNO->WriteToSnoMask('d', "NOT Applying modes from other side");
-                       apply_other_sides_umodes = false;
-                       apply_other_sides_cmodes = false;
+                       apply_other_sides_modes = false;
                }
                else if (ourTS > TS)
                {
@@ -106,25 +105,12 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                        param_list.push_back(channel);
                        this->RemoveStatus(ServerInstance->Config->GetSID(), param_list);
                }
-               else
-               {
-                       /* Timestamp equal. Apply the user modes always */
-                       apply_other_sides_umodes = true;
-                       /*
-                        * If the server is bursting, then the channel modes need to be applied;
-                        * it is expected that servers will resync modes at this time. Otherwise,
-                        * the mode string sent along with the FJOIN could be out-of-date, and
-                        * applying the mode change could cause modes to be unexpectedly bounced.
-                        */
-                       TreeServer *s = Utils->FindServer(source);
-                       apply_other_sides_cmodes = s->bursting;
-               }
+               // The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on.
        }
 
        /* First up, apply their modes if they won the TS war */
-       if (apply_other_sides_cmodes)
+       if (apply_other_sides_modes)
        {
-               ServerInstance->SNO->WriteToSnoMask('d', "Applying remote modestring for %s", params[0].c_str());
                unsigned int idx = 2;
                std::vector<std::string> modelist;
 
@@ -182,7 +168,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                                for (std::string::iterator x = modes.begin(); x != modes.end(); ++x)
                                        modestack.Push(*x, who->nick);
 
-                               Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", true, TS);
+                               Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", route_back_again->bursting, TS);
                        }
                        else
                        {
@@ -193,7 +179,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        }
 
        /* Flush mode stacker if we lost the FJOIN or had equal TS */
-       if (apply_other_sides_umodes)
+       if (apply_other_sides_modes)
        {
                std::deque<std::string> stackresult;
                std::vector<std::string> mode_junk;
@@ -201,11 +187,9 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
 
                while (modestack.GetStackedLine(stackresult))
                {
-                       for (size_t j = 0; j < stackresult.size(); j++)
-                       {
-                               mode_junk.push_back(stackresult[j]);
-                       }
+                       mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
                        ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
+                       mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
                }
        }
 
@@ -240,10 +224,9 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string>
 
                while (stack.GetStackedLine(stackresult))
                {
-                       for (size_t j = 0; j < stackresult.size(); j++)
-                               mode_junk.push_back(stackresult[j]);
-
+                       mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
                        ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
+                       mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
                }
        }
        return true;