Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-01-23 02:23:45 UTC
Modified files:
Tag: u2_10_12_branch
ChangeLog ircd/channel.c
Added files:
Tag: u2_10_12_branch
tests/bug-1640796.cmd
Log message:
Fix SF bug #1640796; add a test for it.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.144 ircu2.10/ChangeLog:1.710.2.145
--- ircu2.10/ChangeLog:1.710.2.144 Mon Jan 22 18:19:44 2007
+++ ircu2.10/ChangeLog Mon Jan 22 18:23:26 2007
@@ -1,5 +1,12 @@
2007-01-22 Michael Poole <[EMAIL PROTECTED]>
+ * ircd/channel.c (find_delayed_joins): New function.
+ (modebuf_flush): Handle +D-D and related cases.
+ (mode_parse_mode): It is too early to handle +D here, so don't.
+ (CheckDelayedJoins): Use find_delayed_joins().
+
+2007-01-22 Michael Poole <[EMAIL PROTECTED]>
+
* tests: New subdirectory for test framework.
* tests/ircd.conf: Helper file for testing.
Index: ircu2.10/ircd/channel.c
diff -u ircu2.10/ircd/channel.c:1.155.2.16 ircu2.10/ircd/channel.c:1.155.2.17
--- ircu2.10/ircd/channel.c:1.155.2.16 Sat Nov 4 13:35:28 2006
+++ ircu2.10/ircd/channel.c Mon Jan 22 18:23:34 2007
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Channel management and maintenance
- * @version $Id: channel.c,v 1.155.2.16 2006/11/04 21:35:28 entrope Exp $
+ * @version $Id: channel.c,v 1.155.2.17 2007/01/23 02:23:34 entrope Exp $
*/
#include "config.h"
@@ -2049,6 +2049,20 @@
modebuf_flush_int(mbuf, 0);
}
+/** Check a channel for join-delayed members.
+ * @param[in] chan Channel to search.
+ * @return Non-zero if any members are join-delayed; false if none are.
+ */
+static int
+find_delayed_joins(const struct Channel *chan)
+{
+ const struct Membership *memb;
+ for (memb = chan->members; memb; memb = memb->next_member)
+ if (IsDelayedJoin(memb))
+ return 1;
+ return 0;
+}
+
/** The exported binding for modebuf_flush()
*
* @param mbuf The mode buffer to flush.
@@ -2058,19 +2072,22 @@
int
modebuf_flush(struct ModeBuf *mbuf)
{
- struct Membership *memb;
-
- /* Check if MODE_WASDELJOINS should be set */
- if (!(mbuf->mb_channel->mode.mode & (MODE_DELJOINS | MODE_WASDELJOINS))
- && (mbuf->mb_rem & MODE_DELJOINS)) {
- for (memb = mbuf->mb_channel->members; memb; memb = memb->next_member) {
- if (IsDelayedJoin(memb)) {
- mbuf->mb_channel->mode.mode |= MODE_WASDELJOINS;
- mbuf->mb_add |= MODE_WASDELJOINS;
- mbuf->mb_rem &= ~MODE_WASDELJOINS;
- break;
- }
- }
+ /* Check if MODE_WASDELJOINS should be set: */
+ /* Must be set if going -D and some clients are hidden */
+ if ((mbuf->mb_rem & MODE_DELJOINS)
+ && !(mbuf->mb_channel->mode.mode & (MODE_DELJOINS | MODE_WASDELJOINS))
+ && find_delayed_joins(mbuf->mb_channel)) {
+ mbuf->mb_channel->mode.mode |= MODE_WASDELJOINS;
+ mbuf->mb_add |= MODE_WASDELJOINS;
+ mbuf->mb_rem &= ~MODE_WASDELJOINS;
+ }
+ /* Must be cleared if +D is set */
+ if ((mbuf->mb_add & MODE_DELJOINS)
+ && ((mbuf->mb_channel->mode.mode & (MODE_WASDELJOINS | MODE_WASDELJOINS))
+ == (MODE_WASDELJOINS | MODE_WASDELJOINS))) {
+ mbuf->mb_channel->mode.mode &= ~MODE_WASDELJOINS;
+ mbuf->mb_add &= ~MODE_WASDELJOINS;
+ mbuf->mb_rem |= MODE_WASDELJOINS;
}
return modebuf_flush_int(mbuf, 1);
@@ -3138,10 +3155,6 @@
state->add &= ~MODE_SECRET;
state->del |= MODE_SECRET;
}
- if (flag_p[0] & MODE_DELJOINS) {
- state->add &= ~MODE_WASDELJOINS;
- state->del |= MODE_WASDELJOINS;
- }
} else {
state->add &= ~flag_p[0];
state->del |= flag_p[0];
@@ -3576,18 +3589,9 @@
void CheckDelayedJoins(struct Channel *chan)
{
- struct Membership *memb2;
-
- if (chan->mode.mode & MODE_WASDELJOINS) {
- for (memb2=chan->members;memb2;memb2=memb2->next_member)
- if (IsDelayedJoin(memb2))
- break;
-
- if (!memb2) {
- /* clear +d */
- chan->mode.mode &= ~MODE_WASDELJOINS;
- sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan, NULL, 0,
- "%H -d", chan);
- }
+ if ((chan->mode.mode & MODE_WASDELJOINS) && !find_delayed_joins(chan)) {
+ chan->mode.mode &= ~MODE_WASDELJOINS;
+ sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan, NULL, 0,
+ "%H -d", chan);
}
}
Index: ircu2.10/tests/bug-1640796.cmd
diff -u /dev/null ircu2.10/tests/bug-1640796.cmd:1.1.2.1
--- /dev/null Mon Jan 22 18:23:47 2007
+++ ircu2.10/tests/bug-1640796.cmd Mon Jan 22 18:23:35 2007
@@ -0,0 +1,35 @@
+define srv1 localhost:7601
+define srv1-name irc.example.net
+define hidden-srv *.undernet.org
+define channel #random-channel
+define cl1-nick Ch4n0pm4n
+define cl2-nick D00dm4n
+
+# Connect two clients. Join one to the test channel.
+connect cl1 %cl1-nick% op3rm4n %srv1% :Some Chanop
+connect cl2 %cl2-nick% d00dm4n %srv1% :Someone Else
+:cl1 join %channel%
+:cl1 mode %channel% +D
+:cl1 expect %cl1-nick% mode %channel% \\+D
+
+# Now join the other client, and let the chanop remove -D. Both
+# should see the channel become +d.
+:cl2 wait cl1
+:cl2 join %channel%
+:cl1 wait cl2
+:cl1 mode %channel% -D
+:cl1 expect %cl1-nick% mode %channel% -D\\+d
+:cl2 expect %cl1-nick% mode %channel% -D\\+d
+
+# Bug 1640796 is that if the chanop sends +D-D, the channel is
+# improperly marked -d. (An empty mode change is also sent to other
+# servers.)
+:cl1 mode %channel% +D-D
+:cl1 mode %channel%
+:cl1 expect %srv1-name% 324 %cl1-nick% %channel% \\+.*d
+
+# Make sure that client 1 does see the -d when client 2 quits
+:cl2 wait cl1
+:cl2 part %channel% leaving
+:cl1 expect %hidden-srv% mode %channel% -d
+:cl1 quit done
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches