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

[or-cvs] r9992: Fix a bug in displaying memory pool usage. Also dump cell al (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2007-04-19 15:52:30 -0400 (Thu, 19 Apr 2007)
New Revision: 9992

Modified:
   tor/trunk/
   tor/trunk/src/common/mempool.c
   tor/trunk/src/or/relay.c
Log:
 r12458@catbus:  nickm | 2007-04-19 15:52:23 -0400
 Fix a bug in displaying memory pool usage.  Also dump cell allocation, and track padded_cell_ts as they are allocated and freed, to make sure we are not leaking cells.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12458] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/mempool.c
===================================================================
--- tor/trunk/src/common/mempool.c	2007-04-19 18:47:04 UTC (rev 9991)
+++ tor/trunk/src/common/mempool.c	2007-04-19 19:52:30 UTC (rev 9992)
@@ -517,7 +517,7 @@
          " bytes in %d partially full chunks",
          U64_PRINTF_ARG(bu), U64_PRINTF_ARG(ba), n_used);
   bytes_used += bu;
-  bytes_allocated += bu;
+  bytes_allocated += ba;
   bu = ba = 0;
   for (chunk = pool->full_chunks; chunk; chunk = chunk->next) {
     ++n_full;
@@ -528,7 +528,7 @@
          " bytes in %d full chunks",
          U64_PRINTF_ARG(bu), U64_PRINTF_ARG(ba), n_full);
   bytes_used += bu;
-  bytes_allocated += bu;
+  bytes_allocated += ba;
 
   log_fn(severity, LD_MM, "Total: "U64_FORMAT"/"U64_FORMAT" bytes allocated "
          "for cell pools are full.",

Modified: tor/trunk/src/or/relay.c
===================================================================
--- tor/trunk/src/or/relay.c	2007-04-19 18:47:04 UTC (rev 9991)
+++ tor/trunk/src/or/relay.c	2007-04-19 19:52:30 UTC (rev 9992)
@@ -1478,6 +1478,9 @@
 #define assert_active_circuits_ok_paranoid(conn)
 #endif
 
+/** DOCDOC */
+static int total_cells_allocated = 0;
+
 #ifdef ENABLE_CELL_POOL
 static mp_pool_t *cell_pool = NULL;
 /** Allocate structures to hold cells. */
@@ -1509,6 +1512,7 @@
 static INLINE void
 packed_cell_free(packed_cell_t *cell)
 {
+  --total_cells_allocated;
   mp_pool_release(cell);
 }
 
@@ -1516,11 +1520,23 @@
 static INLINE packed_cell_t *
 packed_cell_alloc(void)
 {
+  ++total_cells_allocated;
   return mp_pool_get(cell_pool);
 }
 void
 dump_cell_pool_usage(int severity)
 {
+  circuit_t *c;
+  int n_circs = 0;
+  int n_cells = 0;
+  for (c = _circuit_get_global_list(); c; c = c->next) {
+    n_cells += c->n_conn_cells.n;
+    if (!CIRCUIT_IS_ORIGIN(c))
+      n_cells += TO_OR_CIRCUIT(c)->p_conn_cells.n;
+    ++n_circs;
+  }
+  log(severity, LD_MM, "%d cells allocated on %d circuits. %d cells leaked.",
+      n_cells, n_circs, total_cells_allocated - n_cells);
   mp_pool_log_status(cell_pool, severity);
 }
 #else
@@ -1544,12 +1560,14 @@
 static INLINE void
 packed_cell_free(packed_cell_t *cell)
 {
+  --total_cells_allocated;
   tor_free(cell);
 }
 
 static INLINE packed_cell_t *
 packed_cell_alloc(void)
 {
+  ++total_cells_allocated;
   return tor_malloc(sizeof(packed_cell_t));
 }
 void