summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-04-08 13:37:57 -0400
committerNick Mathewson <nickm@torproject.org>2011-04-08 13:37:57 -0400
commit99c2bfe76b48f8a142682c2729236d5e4e63ec25 (patch)
tree098890cdffda2fd318bfc5fecf4c348fa8ad1202 /src/or/rephist.c
parent85ac832a1474e274ff4a6ad9444cf5e0ab12450e (diff)
parente247705afefaa0f32ccbc43185f98fc65f041af1 (diff)
downloadtor-99c2bfe76b48f8a142682c2729236d5e4e63ec25.tar.gz
tor-99c2bfe76b48f8a142682c2729236d5e4e63ec25.zip
Merge remote-tracking branch 'origin/maint-0.2.2'
Conflicts: src/or/rephist.c
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 56a3d1de28..d6b4a03a64 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2320,13 +2320,19 @@ rep_hist_buffer_stats_init(time_t now)
start_of_buffer_stats_interval = now;
}
+/** Statistics from a single circuit. Collected when the circuit closes, or
+ * when we flush statistics to disk. */
typedef struct circ_buffer_stats_t {
- uint32_t processed_cells;
+ /** Average number of cells in the circuit's queue */
double mean_num_cells_in_queue;
+ /** Average time a cell waits in the queue. */
double mean_time_cells_in_queue;
+ /** Total number of cells sent over this circuit */
+ uint32_t processed_cells;
} circ_buffer_stats_t;
-smartlist_t *circuits_for_buffer_stats = NULL;
+/** List of circ_buffer_stats_t. */
+static smartlist_t *circuits_for_buffer_stats = NULL;
/** Remember cell statistics for circuit <b>circ</b> at time
* <b>end_of_interval</b> and reset cell counters in case the circuit
@@ -2350,6 +2356,8 @@ rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval)
circ->timestamp_created.tv_sec :
start_of_buffer_stats_interval;
interval_length = (int) (end_of_interval - start_of_interval);
+ if (interval_length <= 0)
+ return;
stat = tor_malloc_zero(sizeof(circ_buffer_stats_t));
stat->processed_cells = orcirc->processed_cells;
/* 1000.0 for s -> ms; 2.0 because of app-ward and exit-ward queues */
@@ -2749,5 +2757,12 @@ rep_hist_free_all(void)
built_last_stability_doc_at = 0;
predicted_ports_free();
bidi_map_free();
+
+ if (circuits_for_buffer_stats) {
+ SMARTLIST_FOREACH(circuits_for_buffer_stats, circ_buffer_stats_t *, s,
+ tor_free(s));
+ smartlist_free(circuits_for_buffer_stats);
+ circuits_for_buffer_stats = NULL;
+ }
}