Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2005-05-30 13:17:07 UTC

Modified files:
     ircd/s_user.c ChangeLog

Log message:

Reduce number of branches in register_user().

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.634 ircu2.10/ChangeLog:1.635
--- ircu2.10/ChangeLog:1.634    Mon May 30 06:14:54 2005
+++ ircu2.10/ChangeLog  Mon May 30 06:16:57 2005
@@ -6,6 +6,9 @@
        * ircd/m_endburst.c (ms_endofburst): Avoid dereferencing 'chan'
        after it may be freed (in sub1_from_channel).
 
+       * ircd/s_user.c (register_user): Rearrange code to reduce number
+       of "if (MyConnect(sptr))" checks.
+
 2005-05-12  Michael Poole <[EMAIL PROTECTED]>
 
        * configure.in: Do not try to outsmart the default CFLAGS.
Index: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.95 ircu2.10/ircd/s_user.c:1.96
--- ircu2.10/ircd/s_user.c:1.95 Thu May  5 20:42:25 2005
+++ ircu2.10/ircd/s_user.c      Mon May 30 06:16:55 2005
@@ -22,7 +22,7 @@
  */
 /** @file
  * @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.c,v 1.95 2005/05/06 03:42:25 entrope Exp $
+ * @version $Id: s_user.c,v 1.96 2005/05/30 13:16:55 entrope Exp $
  */
 #include "config.h"
 
@@ -564,19 +564,8 @@
       return exit_client(cptr, sptr, &me, "USER: Bad username");
     }
     Count_unknownbecomesclient(sptr, UserStats);
-  }
-  else {
-    ircd_strncpy(user->username, username, USERLEN);
-    Count_newremoteclient(UserStats, user->server);
-  }
-  SetUser(sptr);
 
-  if (IsInvisible(sptr))
-    ++UserStats.inv_clients;
-  if (IsOper(sptr))
-    ++UserStats.opers;
-
-  if (MyConnect(sptr)) {
+    SetUser(sptr);
     cli_handler(sptr) = CLIENT_HANDLER;
     release_dns_reply(sptr);
     SetLocalNumNick(sptr);
@@ -597,7 +586,6 @@
     m_lusers(sptr, sptr, 1, parv);
     update_load();
     motd_signon(sptr);
-/*      nextping = CurrentTime; */
     if (cli_snomask(sptr) & SNO_NOISY)
       set_snomask(sptr, cli_snomask(sptr) & SNO_NOISY, SNO_ADD);
     if (feature_bool(FEAT_CONNEXIT_NOTICES))
@@ -626,7 +614,6 @@
         break;
       case 'i':
         SetInvisible(sptr);
-        ++UserStats.inv_clients;
         break;
       case 'd':
         SetDeaf(sptr);
@@ -638,11 +625,12 @@
       }
     }
   }
-  else
-    /* if (IsServer(cptr)) */
-  {
+  else {
     struct Client *acptr;
 
+    ircd_strncpy(user->username, username, USERLEN);
+    Count_newremoteclient(UserStats, user->server);
+
     acptr = user->server;
     if (cli_from(acptr) != cli_from(sptr))
     {
@@ -661,7 +649,7 @@
      * FIXME: This can be sped up - its stupid to check it for
      * every NICK message in a burst again  --Run.
      */
-    for (acptr = user->server; acptr != &me; acptr = cli_serv(acptr)->up)
+    for (; acptr != &me; acptr = cli_serv(acptr)->up)
     {
       if (IsBurst(acptr) || Protocol(acptr) < 10)
         break;
@@ -675,7 +663,14 @@
                     sptr, cli_name(&me));
       return exit_client(cptr, sptr, &me,"Too many connections from your host 
-- throttled");
     }
+    SetUser(sptr);
   }
+
+  if (IsInvisible(sptr))
+    ++UserStats.inv_clients;
+  if (IsOper(sptr))
+    ++UserStats.opers;
+
   tmpstr = umode_str(sptr);
   /* Send full IP address to IPv6-grokking servers. */
   sendcmdto_flag_serv_butone(user->server, CMD_NICK, cptr,
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to