Browse Source

* Removed HOOK_DAILY
* Traffic stats on leaf bots now cleared correctly once per day


svn: 898

Bryan Drewery 22 năm trước cách đây
mục cha
commit
06a887a415
3 tập tin đã thay đổi với 27 bổ sung33 xóa
  1. 1 0
      doc/UPDATES
  2. 2 3
      src/hooks.h
  3. 24 30
      src/main.c

+ 1 - 0
doc/UPDATES

@@ -7,6 +7,7 @@ This is a summary of ChangeLog basically.
 3.Fixed a bug in transfer/update which caused transfers to fail often.
 4.Segfault fix in cmd_debug.
 5.Fixed a potential bug in share.
+6.Traffic stats are now properly cleared on leaf bots every day.
 
 1.1.4 (Quickly advanced to 1.1.5)
 

+ 2 - 3
src/hooks.h

@@ -7,9 +7,8 @@
 #define HOOK_USERFILE             2
 #define HOOK_PRE_REHASH           3
 #define HOOK_IDLE                 4
-#define HOOK_BACKUP               5
-#define HOOK_DAILY                8
-#define REAL_HOOKS                9
+#define HOOK_BACKUP               6
+#define REAL_HOOKS                7
 
 #define HOOK_RFC_CASECMP        111
 

+ 24 - 30
src/main.c

@@ -132,11 +132,6 @@ static char *getfullbinname(const char *argv_zero)
   return bin;
 }
 
-
-/* Traffic stats
- */
-egg_traffic_t traffic;
-
 void fatal(const char *s, int recoverable)
 {
   int i = 0;
@@ -392,6 +387,29 @@ void core_10secondly()
 #endif /* LEAF */
 }
 
+/* Traffic stats
+ */
+egg_traffic_t traffic;
+
+static void event_resettraffic()
+{
+	traffic.out_total.irc += traffic.out_today.irc;
+	traffic.out_total.bn += traffic.out_today.bn;
+	traffic.out_total.dcc += traffic.out_today.dcc;
+	traffic.out_total.filesys += traffic.out_today.filesys;
+	traffic.out_total.trans += traffic.out_today.trans;
+	traffic.out_total.unknown += traffic.out_today.unknown;
+
+	traffic.in_total.irc += traffic.in_today.irc;
+	traffic.in_total.bn += traffic.in_today.bn;
+	traffic.in_total.dcc += traffic.in_today.dcc;
+	traffic.in_total.filesys += traffic.in_today.filesys;
+	traffic.in_total.trans += traffic.in_today.trans;
+	traffic.in_total.unknown += traffic.in_today.unknown;
+
+	egg_memset(&traffic.out_today, 0, sizeof(traffic.out_today));
+	egg_memset(&traffic.in_today, 0, sizeof(traffic.in_today));
+}
 
 static void core_secondly()
 {
@@ -445,10 +463,8 @@ static void core_secondly()
     /* These no longer need checking since they are all check vs minutely
      * settings and we only get this far on the minute.
      */
-#ifdef HUB
     if (miltime == 300)
-      call_hook(HOOK_DAILY);
-#endif /* HUB */
+      event_resettraffic();
   }
 }
 
@@ -472,26 +488,6 @@ static void core_halfhourly()
 #endif /* HUB */
 }
 
-static void event_resettraffic()
-{
-	traffic.out_total.irc += traffic.out_today.irc;
-	traffic.out_total.bn += traffic.out_today.bn;
-	traffic.out_total.dcc += traffic.out_today.dcc;
-	traffic.out_total.filesys += traffic.out_today.filesys;
-	traffic.out_total.trans += traffic.out_today.trans;
-	traffic.out_total.unknown += traffic.out_today.unknown;
-
-	traffic.in_total.irc += traffic.in_today.irc;
-	traffic.in_total.bn += traffic.in_today.bn;
-	traffic.in_total.dcc += traffic.in_today.dcc;
-	traffic.in_total.filesys += traffic.in_today.filesys;
-	traffic.in_total.trans += traffic.in_today.trans;
-	traffic.in_total.unknown += traffic.in_today.unknown;
-
-	egg_memset(&traffic.out_today, 0, sizeof(traffic.out_today));
-	egg_memset(&traffic.in_today, 0, sizeof(traffic.in_today));
-}
-
 static void startup_checks() {
   char cfile[DIRMAX] = "";
   int enc = CONF_ENC;
@@ -893,8 +889,6 @@ int main(int argc, char **argv)
   timer_create_secs(3600, "core_hourly", (Function) core_hourly);
   timer_create_secs(1800, "core_halfhourly", (Function) core_halfhourly);
 
-  add_hook(HOOK_DAILY, (Function) event_resettraffic);
-
   debug0("main: entering loop");
 
   while (1) {