[cvslog] (2005-09-05 03:27:19 UTC) Module eggdrop1.7: Change committed!

cvslog cvs at tsss.org
Sun Sep 4 21:27:19 CST 2005


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2005-09-05 03:27:19 UTC
Commited by: Will Buckner <wcc at techmonkeys.org>

Modified files:
     src/botnet.c src/main.c src/patch.h

Log message:

* misc.h needs to be included in botnet.c.
* Fixed a little bug where the "stagnent module" warning in main() might
  not be printed.
* More mainloop cleanups.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/botnet.c
diff -u eggdrop1.7/src/botnet.c:1.14 eggdrop1.7/src/botnet.c:1.15
--- eggdrop1.7/src/botnet.c:1.14	Thu Sep  1 21:46:06 2005
+++ eggdrop1.7/src/botnet.c	Sun Sep  4 22:27:09 2005
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: botnet.c,v 1.14 2005/09/02 02:46:06 lordares Exp $
+ * $Id: botnet.c,v 1.15 2005/09/05 03:27:09 wcc Exp $
  */
 
 #include "main.h"
@@ -31,6 +31,7 @@
                       * new_dcc, changeover_dcc */
 #include "dns.h"     /* RES_*, dcc_dnsipbyhost */
 #include "logfile.h" /* putlog, LOG_* */
+#include "misc.h"    /* strncpyz */
 #include "mem.h"     /* nmalloc, nrealloc, nfree */
 #include "net.h"     /* SOCK_*, getsock, killsock, open_telnet_raw, tputs, iptostr */
 #include "userrec.h" /* correct_handle, touch_laston */
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.23 eggdrop1.7/src/main.c:1.24
--- eggdrop1.7/src/main.c:1.23	Tue Aug 30 21:35:13 2005
+++ eggdrop1.7/src/main.c	Sun Sep  4 22:27:09 2005
@@ -19,7 +19,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: main.c,v 1.23 2005/08/31 02:35:13 wcc Exp $
+ * $Id: main.c,v 1.24 2005/09/05 03:27:09 wcc Exp $
  */
 
 #include "main.h"
@@ -298,8 +298,9 @@
       }
     }
   }
-  else
+  else {
     strncpyz(configfile, s, sizeof configfile);
+  }
 }
 
 static void readconfig()
@@ -783,6 +784,8 @@
   add_help_reference("cmds1.help");
   add_help_reference("cmds2.help");
   add_help_reference("core.help");
+
+  /* Create hooks. */
   add_hook(HOOK_SECONDLY, (Function) core_secondly);
   add_hook(HOOK_MINUTELY, (Function) core_minutely);
   add_hook(HOOK_HOURLY, (Function) core_hourly);
@@ -803,14 +806,13 @@
 #ifdef USE_TCL_EVENTS
     /* Process a single Tcl event. */
     Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
-#endif /* USE_TCL_EVENTS */
+#endif
 
-    /* Lets move some of this here, reducing the numer of actual
-     * calls to periodic_timers
-     */
     now = time(NULL);
-    random();                   /* Woop, lets really jumble things */
-    if (now != then) {          /* Once a second */
+    random();
+
+    /* Every second... */
+    if (now != then) {
       call_hook(HOOK_SECONDLY);
       then = now;
     }
@@ -825,49 +827,57 @@
       /* Check for server or dcc activity. */
       dequeue_sockets();
     }
-    else
+    else {
       socket_cleanup--;
+    }
 
     /* Free unused structures. */
     garbage_collect();
 
     xx = sockgets(buf, &i);
-    if (xx >= 0) {              /* Non-error */
+    if (xx >= 0) { /* Non-error */
       int idx;
 
       for (idx = 0; idx < dcc_total; idx++) {
-        if (dcc[idx].sock == xx) {
-          if (dcc[idx].type && dcc[idx].type->activity) {
-            traffic_update_in(dcc[idx].type, (strlen(buf) + 1)); /* Traffic stats. */
-            dcc[idx].type->activity(idx, buf, i);
-          }
-          else
-            putlog(LOG_MISC, "*",
-                   "!!! untrapped dcc activity: type %s, sock %d",
-                   dcc[idx].type->name, dcc[idx].sock);
-          break;
+        if (dcc[idx].sock != xx)
+          continue;
+
+        if (dcc[idx].type && dcc[idx].type->activity) {
+          traffic_update_in(dcc[idx].type, (strlen(buf) + 1)); /* Traffic stats. */
+          dcc[idx].type->activity(idx, buf, i);
+        }
+        else {
+          putlog(LOG_MISC, "*", "!!! untrapped dcc activity: type %s, sock %d",
+                 dcc[idx].type->name, dcc[idx].sock);
         }
+
+        break;
       }
     }
-    else if (xx == -1) {        /* EOF from someone */
+    else if (xx == -1) { /* EOF */
       int idx;
 
       if (i == STDOUT && !backgrd)
         fatal("END OF FILE ON TERMINAL", 0);
+
       for (idx = 0; idx < dcc_total; idx++) {
-        if (dcc[idx].sock == i) {
-          if (dcc[idx].type && dcc[idx].type->eof)
-            dcc[idx].type->eof(idx);
-          else {
-            putlog(LOG_MISC, "*",
-                   "*** ATTENTION: DEAD SOCKET (%d) OF TYPE %s UNTRAPPED",
-                   i, dcc[idx].type ? dcc[idx].type->name : "*UNKNOWN*");
-            killsock(i);
-            lostdcc(idx);
-          }
-          idx = dcc_total + 1;
+        if (dcc[idx].sock != i)
+          continue;
+
+        if (dcc[idx].type && dcc[idx].type->eof) {
+          dcc[idx].type->eof(idx);
         }
+        else {
+          putlog(LOG_MISC, "*",
+                 "*** ATTENTION: DEAD SOCKET (%d) OF TYPE %s UNTRAPPED",
+                 i, dcc[idx].type ? dcc[idx].type->name : "*UNKNOWN*");
+          killsock(i);
+          lostdcc(idx);
+        }
+
+        idx = dcc_total + 1;
       }
+
       if (idx == dcc_total) {
         putlog(LOG_MISC, "*",
                "(@) EOF socket %d, not a dcc socket, not anything.", i);
@@ -875,7 +885,7 @@
         killsock(i);
       }
     }
-    else if (xx == -2 && errno != EINTR) {      /* select() error */
+    else if (xx == -2 && errno != EINTR) { /* select() error */
       putlog(LOG_MISC, "*", "* Socket error #%d; recovering.", errno);
       for (i = 0; i < dcc_total; i++) {
         if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno == EBADF)) {
@@ -894,20 +904,22 @@
     }
 
     if (do_restart) {
-      if (do_restart == -2)
+      if (do_restart == -2) {
         rehash();
+      }
       else {
-        /* Unload as many modules as possible */
         int f = 1;
         module_entry *p;
-        Function x;
-        char xx[256];
+        Function startfunc;
+        char name[256];
+
 
-        /* oops, I guess we should call this event before tcl is restarted */
         check_tcl_event("prerestart");
 
+        /* Unload as many modules as possible */
         while (f) {
           f = 0;
+
           for (p = module_list; p != NULL; p = p->next) {
             dependancy *d = dependancy_list;
             int ok = 1;
@@ -915,11 +927,13 @@
             while (ok && d) {
               if (d->needed == p)
                 ok = 0;
+
               d = d->next;
             }
             if (ok) {
-              strcpy(xx, p->name);
-              if (module_unload(xx, botnetnick) == NULL) {
+              strcpy(name, p->name);
+
+              if (module_unload(name, botnetnick) == NULL) {
                 f = 1;
                 break;
               }
@@ -927,30 +941,37 @@
           }
         }
 
+        /* Make sure we don't have any modules left hanging around other than
+         * "eggdrop" and the two that are supposed to be.
+         */
         for (f = 0, p = module_list; p; p = p->next) {
-          if (!strcmp(p->name, "eggdrop") || !strcmp(p->name, "encryption") ||
-              !strcmp(p->name, "uptime"))
-            f = 0;
-          else
-            f = 1;
+          if (strcmp(p->name, "eggdrop") && strcmp(p->name, "encryption") &&
+              strcmp(p->name, "uptime")) {
+            f++;
+          }
         }
-        if (f)
-          /* Should be only 3 modules now - eggdrop, encryption, and uptime */
+        if (f != 0) {
           putlog(LOG_MISC, "*", MOD_STAGNANT);
+        }
 
+        /* Flush log files to disk. */
         flushlogs();
+
+        /* Clean up Tcl stuff. */
         kill_tcl();
+
+        /* Initialize stuff again. */
         init_tcl(argc, argv);
         init_language(0);
         help_init();
         traffic_init();
         logfile_init(1);
 
-        /* this resets our modules which we didn't unload (encryption and uptime) */
+        /* This resets our modules which we didn't unload (encryption and uptime). */
         for (p = module_list; p; p = p->next) {
           if (p->funcs) {
-            x = p->funcs[MODCALL_START];
-            x(NULL);
+            startfunc = p->funcs[MODCALL_START];
+            startfunc(NULL);
           }
         }
 
@@ -958,6 +979,7 @@
         restart_chons();
         call_hook(HOOK_LOADED);
       }
+
       do_restart = 0;
     }
   }
Index: eggdrop1.7/src/patch.h
diff -u eggdrop1.7/src/patch.h:1.51 eggdrop1.7/src/patch.h:1.52
--- eggdrop1.7/src/patch.h:1.51	Tue Aug 30 21:35:13 2005
+++ eggdrop1.7/src/patch.h	Sun Sep  4 22:27:09 2005
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.51 2005/08/31 02:35:13 wcc Exp $
+ * $Id: patch.h,v 1.52 2005/09/05 03:27:09 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1125455640");            /* current unixtime */
+patch("1125888917");            /* current unixtime */
 /*
  *
  *
  */
-patch("valgrind-bitching");
+patch("mainloop-cleanups");
 /*
  *
  *
----------------------- End of diff -----------------------



More information about the Changes mailing list