Revision: 1913
          
http://undernet-ircu.svn.sourceforge.net/undernet-ircu/?rev=1913&view=rev
Author:   entrope
Date:     2009-07-04 22:46:00 +0000 (Sat, 04 Jul 2009)

Log Message:
-----------
Attempt to fix SF bug #2568366 (sending JOIN before hitting a target limit).

Modified Paths:
--------------
    ircu2/branches/u2_10_12_branch/ChangeLog
    ircu2/branches/u2_10_12_branch/include/channel.h
    ircu2/branches/u2_10_12_branch/include/gline.h
    ircu2/branches/u2_10_12_branch/ircd/channel.c
    ircu2/branches/u2_10_12_branch/ircd/ircd_relay.c
    ircu2/branches/u2_10_12_branch/ircd/m_wallchops.c
    ircu2/branches/u2_10_12_branch/ircd/m_wallvoices.c
    ircu2/branches/u2_10_12_branch/ircd/s_user.c
    ircu2/branches/u2_10_12_branch/tests/ircd.conf

Modified: ircu2/branches/u2_10_12_branch/ChangeLog
===================================================================
--- ircu2/branches/u2_10_12_branch/ChangeLog    2009-07-04 22:44:19 UTC (rev 
1912)
+++ ircu2/branches/u2_10_12_branch/ChangeLog    2009-07-04 22:46:00 UTC (rev 
1913)
@@ -1,3 +1,20 @@
+2009-07-04  Michael Poole <[email protected]>
+
+       * include/channel.h (RevealDelayedJoinIfNeeded): Declare.
+
+       * ircd/channel.c (RevealDelayedJoinIfNeeded): Implement.
+
+       * ircd/ircd_relay.c (relay_channel_message): Only reveal the user
+       if he passes the check_target_limit() test.
+       (relay_channel_notice): Likewise.
+
+       * ircd/m_wallchops.c (m_wallchops): Likewise.
+
+       * ircd/m_wallvoices.c (m_wallvoices): Likewise.
+
+       * ircd/s_user.c (check_target_limit): Micro-optimize to only check
+       the user's channel list for invites if we are about to deny it.
+
 2009-03-25  Michael Poole <[email protected]>
 
        * ircd/ircd.c (main): Unconditionally set +6 flag on self.

Modified: ircu2/branches/u2_10_12_branch/include/channel.h
===================================================================
--- ircu2/branches/u2_10_12_branch/include/channel.h    2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/include/channel.h    2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -405,6 +405,7 @@
 extern void del_invite(struct Client *cptr, struct Channel *chptr);
 extern void list_set_default(void); /* this belongs elsewhere! */
 
+extern void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel 
*chptr);
 extern void RevealDelayedJoin(struct Membership *member);
 extern void CheckDelayedJoins(struct Channel *chan);
 

Modified: ircu2/branches/u2_10_12_branch/include/gline.h
===================================================================
--- ircu2/branches/u2_10_12_branch/include/gline.h      2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/include/gline.h      2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -50,13 +50,13 @@
   struct Gline *gl_next;       /**< Next G-line in linked list. */
   struct Gline**gl_prev_p;     /**< Previous pointer to this G-line. */
   char        *gl_user;        /**< Username mask (or channel/realname mask). 
*/
-  char        *gl_host;        /**< Host prtion of mask. */
+  char        *gl_host;        /**< Host portion of mask. */
   char        *gl_reason;      /**< Reason for G-line. */
   time_t       gl_expire;      /**< Expiration timestamp. */
   time_t       gl_lastmod;     /**< Last modification timestamp. */
   time_t       gl_lifetime;    /**< Record expiration timestamp. */
   struct irc_in_addr gl_addr;  /**< IP address (for IP-based G-lines). */
-  unsigned char gl_bits;       /**< Usable bits in gl_addr. */
+  unsigned char gl_bits;       /**< Bits in gl_addr used in the mask. */
   unsigned int gl_flags;       /**< G-line status flags. */
   enum GlineLocalState gl_state;/**< G-line local state. */
 };

Modified: ircu2/branches/u2_10_12_branch/ircd/channel.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/channel.c       2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/ircd/channel.c       2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -3636,3 +3636,12 @@
                                      "%H -d", chan);
   }
 }
+
+/** Send a join for the user if (s)he is a hidden member of the channel.
+ */
+void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel *chptr)
+{
+  struct Membership *member = find_member_link(chptr, sptr);
+  if (member && IsDelayedJoin(member))
+    RevealDelayedJoin(member);
+}

Modified: ircu2/branches/u2_10_12_branch/ircd/ircd_relay.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/ircd_relay.c    2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/ircd/ircd_relay.c    2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -97,7 +97,7 @@
   /*
    * This first: Almost never a server/service
    */
-  if (!client_can_send_to_channel(sptr, chptr, 1)) {
+  if (!client_can_send_to_channel(sptr, chptr, 0)) {
     send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname);
     return;
   }
@@ -105,6 +105,7 @@
       check_target_limit(sptr, chptr, chptr->chname, 0))
     return;
 
+  RevealDelayedJoinIfNeeded(sptr, chptr);
   sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr),
                           SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
 }
@@ -127,13 +128,14 @@
   /*
    * This first: Almost never a server/service
    */
-  if (!client_can_send_to_channel(sptr, chptr, 1))
+  if (!client_can_send_to_channel(sptr, chptr, 0))
     return;
 
   if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
       check_target_limit(sptr, chptr, chptr->chname, 0))
     return;
 
+  RevealDelayedJoinIfNeeded(sptr, chptr);
   sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr),
                           SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
 }

Modified: ircu2/branches/u2_10_12_branch/ircd/m_wallchops.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/m_wallchops.c   2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/ircd/m_wallchops.c   2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -115,10 +115,11 @@
     return send_reply(sptr, ERR_NOTEXTTOSEND);
 
   if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) {
-    if (client_can_send_to_channel(sptr, chptr, 1)) {
+    if (client_can_send_to_channel(sptr, chptr, 0)) {
       if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
           check_target_limit(sptr, chptr, chptr->chname, 0))
         return 0;
+      RevealDelayedJoinIfNeeded(sptr, chptr);
       sendcmdto_channel_butone(sptr, CMD_WALLCHOPS, chptr, cptr,
                               SKIP_DEAF | SKIP_BURST | SKIP_NONOPS,
                               "%H :@ %s", chptr, parv[parc - 1]);

Modified: ircu2/branches/u2_10_12_branch/ircd/m_wallvoices.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/m_wallvoices.c  2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/ircd/m_wallvoices.c  2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -114,10 +114,11 @@
     return send_reply(sptr, ERR_NOTEXTTOSEND);
 
   if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) {
-    if (client_can_send_to_channel(sptr, chptr, 1)) {
+    if (client_can_send_to_channel(sptr, chptr, 0)) {
       if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
           check_target_limit(sptr, chptr, chptr->chname, 0))
         return 0;
+      RevealDelayedJoinIfNeeded(sptr, chptr);
       sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr,
                               SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, 
                               "%H :+ %s", chptr, parv[parc - 1]);

Modified: ircu2/branches/u2_10_12_branch/ircd/s_user.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/s_user.c        2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/ircd/s_user.c        2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -702,10 +702,6 @@
   assert(cli_local(sptr));
   targets = cli_targets(sptr);
 
-  /* If user is invited to channel, give him/her a free target */
-  if (IsChannelName(name) && IsInvited(sptr, target))
-    return 0;
-
   /*
    * Same target as last time?
    */
@@ -723,6 +719,10 @@
    */
   if (!created) {
     if (CurrentTime < cli_nexttarget(sptr)) {
+      /* If user is invited to channel, give him/her a free target */
+      if (IsChannelName(name) && IsInvited(sptr, target))
+        return 0;
+
       if (cli_nexttarget(sptr) - CurrentTime < TARGET_DELAY + 8) {
         /*
          * No server flooding

Modified: ircu2/branches/u2_10_12_branch/tests/ircd.conf
===================================================================
--- ircu2/branches/u2_10_12_branch/tests/ircd.conf      2009-07-04 22:44:19 UTC 
(rev 1912)
+++ ircu2/branches/u2_10_12_branch/tests/ircd.conf      2009-07-04 22:46:00 UTC 
(rev 1913)
@@ -39,4 +39,5 @@
         "HUB" = "TRUE";
         "CONFIG_OPERCMDS" = "TRUE";
         "CHANNELLEN" = "50";
+        "MAXCHANNELSPERUSER" = "20";
 };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to