ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta1/modules/m_tburst.c
(Generate patch)

Comparing ircd-hybrid-7.2/modules/m_tburst.c (file contents):
Revision 335 by michael, Mon Dec 26 10:36:42 2005 UTC vs.
Revision 336 by michael, Mon Dec 26 18:31:08 2005 UTC

# Line 95 | Line 95 | ms_tburst(struct Client *client_p, struc
95            int parc, char *parv[])
96   {
97    struct Channel *chptr = NULL;
98 <  time_t oldchannelts = atol(parv[1]);
99 <  time_t oldtopicts = atol(parv[3]);
98 >  int accept_remote = 0;
99 >  time_t remote_channel_ts = atol(parv[1]);
100 >  time_t remote_topic_ts = atol(parv[3]);
101 >
102 >  /*
103 >   * Do NOT test parv[5] for an empty string and return if true!
104 >   * parv[5] CAN be an empty string, i.e. if the other side wants
105 >   * to unset our topic.  Don't forget: an empty topic is also a
106 >   * valid topic.
107 >   */
108 >
109  
110    if ((chptr = hash_find_channel(parv[2])) == NULL)
111      return;
112  
113 <  /* Only allow topic change if we are the newer TS and server
114 <   * sending TBURST has older TS and topicTS on older TS is
115 <   * newer than current topicTS. -metalrock
116 <   * XXX - Incorrect logic here as discussed on IRC
113 >  /*
114 >   * The logic for accepting and rejecting channel topics was
115 >   * always a bit hairy, so now we got exactly 2 cases where
116 >   * we would accept a bursted topic
117 >   *
118 >   * Case 1:
119 >   *        The TS of the remote channel is older than ours
120 >   * Case 2:
121 >   *        The TS of the remote channel is equal to ours AND
122 >   *        the TS of the remote topic is newer than ours
123 >   */
124 >  if (remote_channel_ts < chptr->channelts)
125 >    accept_remote = 1;
126 >  else if (remote_channel_ts == chptr->channelts)
127 >    if (remote_topic_ts > chptr->topic_time)
128 >      accept_remote = 1;
129 >
130 >  if (accept_remote)
131 >  {
132 >    int topic_differs = strcmp(chptr->topic ? chptr->topic : "", parv[5]);
133 >
134 >    set_channel_topic(chptr, parv[5], parv[4], remote_topic_ts);
135 >
136 >    if (topic_differs)
137 >      sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s",
138 >                           ConfigServerHide.hide_servers ? me.name : source_p->name,
139 >                           chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
140 >  }
141 >
142 >  /*
143 >   * Always propagate what we have received, not only if we accept the topic.
144 >   * This will keep other servers in sync.
145     */
146 <  if ((oldchannelts <= chptr->channelts) &&
147 <      ((chptr->topic == NULL) || (oldtopicts > chptr->topic_time)))
148 <    set_topic(source_p, chptr, oldtopicts, parv[4], parv[5]);
146 >  sendto_server(source_p, NULL, chptr, CAP_TBURST, NOCAPS, NOFLAGS,
147 >                ":%s TBURST %s %s %s %s :%s",
148 >                source_p->name, parv[1], parv[2], parv[3], parv[4], parv[5]);
149 >  sendto_server(source_p, NULL, chptr, CAP_TB, CAP_TBURST, NOFLAGS,
150 >                ":%s TB %s %s %s :%s",
151 >                source_p->name, parv[1], parv[2], parv[3], parv[4]);
152   }
153  
154   /* ms_tb()

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)