ソースを参照

* MISC fixes, ie: indenting, small fixes for cpu calls/time

svn: 464
Bryan Drewery 22 年 前
コミット
c8332ebfac
8 ファイル変更66 行追加78 行削除
  1. 1 1
      src/cmds.c
  2. 4 7
      src/main.c
  3. 4 9
      src/misc.c
  4. 1 2
      src/mod/channels.mod/channels.c
  5. 9 12
      src/mod/irc.mod/irc.c
  6. 18 21
      src/mod/server.mod/servmsg.c
  7. 26 26
      src/mod/update.mod/update.c
  8. 3 0
      src/proto.h

+ 1 - 1
src/cmds.c

@@ -1972,8 +1972,8 @@ static void cmd_backup(struct userrec *u, int idx, char *par)
   dprintf(idx, STR("Backing up the channel & user files...\n"));
 #ifdef HUB
   write_userfile(idx);
+  backup_userfile();
 #endif /* HUB */
-  call_hook(HOOK_BACKUP);
 }
 
 static void cmd_trace(struct userrec *u, int idx, char *par)

+ 4 - 7
src/main.c

@@ -732,7 +732,7 @@ void backup_userfile()
   movefile(s, s2);
   copyfile(userfile, s);
 }
-#endif 
+#endif /* HUB */
 
 /* Timer info */
 static int		lastmin = 99;
@@ -753,7 +753,7 @@ void core_10secondly()
 #endif /* LEAF */
     check_promisc();
 
-  if (curcheck==1)
+  if (curcheck == 1)
     check_trace(0);
 
 #ifdef LEAF
@@ -865,7 +865,7 @@ static void core_secondly()
 
   for (idx = 0; idx < dcc_total; idx++) {
     if (dcc[idx].simul > 0) {
-      if ((now - dcc[idx].simultime) == 60) { /* expire simuls after 60 seconds (re-uses idx, so it wont fill up) */
+      if ((now - dcc[idx].simultime) == 20) { /* expire simuls after 20 seconds (re-uses idx, so it wont fill up) */
         dcc[idx].simul = -1;
         lostdcc(idx);
       }
@@ -906,7 +906,7 @@ static void core_secondly()
 	strncpyz(s, ctime(&now), sizeof s);
 #ifdef HUB
 	putlog(LOG_ALL, "*", STR("--- %.11s%s"), s, s + 20);
-	call_hook(HOOK_BACKUP);
+        backup_userfile();
 #endif
       }
     }
@@ -1892,9 +1892,6 @@ Context;
   add_hook(HOOK_REHASH, (Function) event_rehash);
   add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
   add_hook(HOOK_USERFILE, (Function) event_save);
-#ifdef HUB
-  add_hook(HOOK_BACKUP, (Function) backup_userfile);  
-#endif /* HUB */
   add_hook(HOOK_DAILY, (Function) event_resettraffic);
   add_hook(HOOK_LOADED, (Function) event_loaded);
 

+ 4 - 9
src/misc.c

@@ -1022,11 +1022,9 @@ void check_promisc()
 #ifdef S_PROMISC
 #ifdef SIOCGIFCONF
   char buf[8192];
-  struct ifreq ifreq,
-   *ifr;
+  struct ifreq ifreq, *ifr;
   struct ifconf ifcnf;
-  char *cp,
-   *cplim;
+  char *cp, *cplim;
   int sock;
 
   if (!strcmp((char *) CFG_PROMISC.ldata ? CFG_PROMISC.ldata : CFG_PROMISC.gdata ? CFG_PROMISC.gdata : "", STR("nocheck")))
@@ -1068,11 +1066,8 @@ void got_trace(int z)
 void check_trace(int n)
 {
 #ifdef S_ANTITRACE
-  int x,
-    parent,
-    i;
-  struct sigaction sv,
-   *oldsv = NULL;
+  int x, parent, i;
+  struct sigaction sv, *oldsv = NULL;
 
   if (n && !strcmp((char *) CFG_TRACE.ldata ? CFG_TRACE.ldata : CFG_TRACE.gdata ? CFG_TRACE.gdata : "", STR("nocheck")))
     return;

+ 1 - 2
src/mod/channels.mod/channels.c

@@ -303,8 +303,7 @@ void rebalance_roles()
 /* FIXME: needs more testing */
 static void channels_checkslowjoin() {
   struct chanset_t *chan;
-ContextNote("channels_checkslowjoin");
-  for (chan = chanset; chan ; chan = chan->next) {
+  for (chan = chanset; chan; chan = chan->next) {
     /* slowpart */
     if (channel_active(chan) && (chan->channel.parttime) && (chan->channel.parttime < now)) {
       chan->channel.parttime = 0;

+ 9 - 12
src/mod/irc.mod/irc.c

@@ -1563,23 +1563,20 @@ static cmd_t irc_bot[] = {
 
 static void getin_3secondly()
 {
-  if (!server_online)
-    return;
-  else {
-    struct chanset_t *ch;
-    for (ch = chanset; ch; ch = ch->next) {
-      if ((channel_pending(ch) || channel_active(ch)) && (!me_op(ch)))
-        request_op(ch);
+  if (server_online) {
+    struct chanset_t *chan;
+    for (chan = chanset; chan; chan = chan->next) {
+      if ((channel_pending(chan) || channel_active(chan)) && !me_op(chan))
+        request_op(chan);
     }
   }
 }
 
 static void irc_10secondly() {
-  struct chanset_t *ch = chanset;
-
-  for (ch=chanset;ch;ch=ch->next)
-    if (channel_closed(ch))
-      enforce_closed(ch);
+  struct chanset_t *chan;
+  for (chan = chanset; chan; chan = chan->next)
+    if (channel_closed(chan))
+      enforce_closed(chan);
 }
 
 EXPORT_SCOPE char *irc_start();

+ 18 - 21
src/mod/server.mod/servmsg.c

@@ -693,9 +693,7 @@ static int gotwall(char *from, char *msg)
 
 static void server_10secondly()
 {
-  if (!server_online)
-    return;
-  if (keepnick) {
+  if (server_online && keepnick) {
     /* NOTE: now that botname can but upto NICKLEN bytes long,
      * check that it's not just a truncation of the full nick.
      */
@@ -710,26 +708,25 @@ static void server_10secondly()
  */
 static void minutely_checks()
 {
-  static int count = 4;
-  int ok = 0;
-  struct chanset_t *chan;
-
   /* Only check if we have already successfully logged in.  */
-  if (!server_online)
-    return;
-  if (min_servs == 0)
-    return;
-  for (chan = chanset; chan; chan = chan->next)
-    if (channel_active(chan) && chan->channel.members == 1) {
-      ok = 1;
-      break;
+  if (server_online && (min_servs != 0)) {
+    static int count = 4;
+    int ok = 0;
+    struct chanset_t *chan;
+
+    for (chan = chanset; chan; chan = chan->next) {
+      if (channel_active(chan) && chan->channel.members == 1) {
+        ok = 1;
+        break;
+      }
+    }
+    if (!ok)
+      return;
+    count++;
+    if (count >= 5) {
+      dprintf(DP_SERVER, "LUSERS\n");
+      count = 0;
     }
-  if (!ok)
-    return;
-  count++;
-  if (count >= 5) {
-    dprintf(DP_SERVER, "LUSERS\n");
-    count = 0;
   }
 }
 

+ 26 - 26
src/mod/update.mod/update.c

@@ -406,36 +406,36 @@ static void cancel_user_xfer(int idx, void *x)
 int cnt = 0;
 static void check_updates()
 {
-  int i;
-  char buf[1024];
-
-  if (!isupdatehub()) return;
-  cnt++;
-  if ((cnt > 5) && bupdating)  bupdating = 0; //2 minutes should be plenty.
-  if (bupdating) return;
-  cnt = 0;
-
-  for (i = 0; i < dcc_total; i++) {
-    if (dcc[i].type->flags & DCT_BOT && (dcc[i].status & STAT_SHARE) &&
-        !(dcc[i].status & STAT_SENDINGU) && !(dcc[i].status & STAT_OFFEREDU) &&
-        !(dcc[i].status & STAT_UPDATED)) { //only offer binary to bots that are sharing
-
-      dcc[i].status &= ~(STAT_GETTINGU | STAT_SENDINGU |
-                       STAT_OFFEREDU);
-
-      if ((dcc[i].u.bot->bts < buildts) && (isupdatehub())) {
-        putlog(LOG_DEBUG, "@", "Bot: %s has build %lu, offering them %lu", dcc[i].nick, dcc[i].u.bot->bts, buildts);
-        dprintf(i, "sb u?\n");
-        dcc[i].status |= STAT_OFFEREDU;
+  if (isupdatehub()) {
+    int i;
+    char buf[1024];
+
+    cnt++;
+    if ((cnt > 5) && bupdating)  bupdating = 0; //2 minutes should be plenty.
+    if (bupdating) return;
+    cnt = 0;
+
+    for (i = 0; i < dcc_total; i++) {
+      if (dcc[i].type->flags & DCT_BOT && (dcc[i].status & STAT_SHARE) &&
+          !(dcc[i].status & STAT_SENDINGU) && !(dcc[i].status & STAT_OFFEREDU) &&
+          !(dcc[i].status & STAT_UPDATED)) { //only offer binary to bots that are sharing
+
+        dcc[i].status &= ~(STAT_GETTINGU | STAT_SENDINGU |
+                         STAT_OFFEREDU);
+
+        if ((dcc[i].u.bot->bts < buildts) && (isupdatehub())) {
+          putlog(LOG_DEBUG, "@", "Bot: %s has build %lu, offering them %lu", dcc[i].nick, dcc[i].u.bot->bts, buildts);
+          dprintf(i, "sb u?\n");
+          dcc[i].status |= STAT_OFFEREDU;
+        }
       }
     }
+    //send out notice to update remote bots ...
+    sprintf(buf, "nu? %lu", buildts);
+    putallbots(buf);
   }
-
-  //send out notice to update remote bots ...
-  sprintf(buf, "nu? %lu", buildts);
-  putallbots(buf);
 }
-#endif
+#endif /* HUB */
 
 static int update_expmem()
 {

+ 3 - 0
src/proto.h

@@ -178,6 +178,9 @@ void do_boot(int, char *, char *);
 int detect_dcc_flood(time_t *, struct chat_info *, int);
 
 /* main.c */
+#ifdef HUB
+void backup_userfile();
+#endif /* HUB */
 void do_fork();
 int crontab_exists();
 void crontab_create(int);