[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] fix a bug in configuring accounting in options_act()



Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	config.c hibernate.c main.c or.h 
Log Message:
fix a bug in configuring accounting in options_act()


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- config.c	15 Nov 2004 03:53:03 -0000	1.254
+++ config.c	15 Nov 2004 04:01:31 -0000	1.255
@@ -311,7 +311,7 @@
   }
 
   /* Set up accounting */
-  if (get_options()->AccountingMaxKB)
+  if (accounting_is_enabled(options))
     configure_accounting(time(NULL));
 
   if(retry_all_listeners(1) < 0) {

Index: hibernate.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/hibernate.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- hibernate.c	14 Nov 2004 22:53:51 -0000	1.20
+++ hibernate.c	15 Nov 2004 04:01:31 -0000	1.21
@@ -91,6 +91,15 @@
  * Functions for bandwidth accounting.
  * ************/
 
+/** If we want to manage the accounting system and potentially
+ * hibernate, return 1, else return 0.
+ */
+int accounting_is_enabled(or_options_t *options) {
+  if (options->AccountingMaxKB)
+    return 1;
+  return 0;
+}
+
 /** Called from main.c to tell us that <b>seconds</b> seconds have
  * passed, <b>n_read</b> bytes have been read, and <b>n_written</b>
  * bytes have been written. */

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.375
retrieving revision 1.376
diff -u -d -r1.375 -r1.376
--- main.c	14 Nov 2004 22:53:50 -0000	1.375
+++ main.c	15 Nov 2004 04:01:31 -0000	1.376
@@ -556,7 +556,7 @@
 
   /** 1c. If we have to change the accounting interval or record
    * bandwidth used in this accounting interval, do so. */
-  if (options->AccountingMaxKB)
+  if (accounting_is_enabled(options))
     accounting_run_housekeeping(now);
 
   /** 2. Every DirFetchPostPeriod seconds, we get a new directory and
@@ -700,7 +700,7 @@
     seconds_elapsed = current_second ? (now.tv_sec - current_second) : 0;
     stats_n_bytes_read += bytes_read;
     stats_n_bytes_written += bytes_written;
-    if (get_options()->AccountingMaxKB)
+    if (accounting_is_enabled(get_options()))
       accounting_add_bytes(bytes_read, bytes_written, seconds_elapsed);
     control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);
 

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.483
retrieving revision 1.484
diff -u -d -r1.483 -r1.484
--- or.h	14 Nov 2004 22:21:23 -0000	1.483
+++ or.h	15 Nov 2004 04:01:31 -0000	1.484
@@ -1324,6 +1324,7 @@
 
 /********************************* hibernate.c **********************/
 
+int accounting_is_enabled(or_options_t *options);
 void configure_accounting(time_t now);
 void accounting_run_housekeeping(time_t now);
 void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);