summaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-04-19 19:52:30 +0000
committerNick Mathewson <nickm@torproject.org>2007-04-19 19:52:30 +0000
commit6ee5bef092f6abed7019a3e730e9f8f42264eea4 (patch)
treeffaea8ae39229e19d7974ed9acedf791c11e1d36 /src/or/relay.c
parent7392464b8805950be47fddf160efef3d52df7444 (diff)
downloadtor-6ee5bef092f6abed7019a3e730e9f8f42264eea4.tar.gz
tor-6ee5bef092f6abed7019a3e730e9f8f42264eea4.zip
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. svn:r9992
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index a5bea0a717..933d079285 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1478,6 +1478,9 @@ circuit_consider_sending_sendme(circuit_t *circ, crypt_path_t *layer_hint)
#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 @@ clean_cell_pool(void)
static INLINE void
packed_cell_free(packed_cell_t *cell)
{
+ --total_cells_allocated;
mp_pool_release(cell);
}
@@ -1516,11 +1520,23 @@ packed_cell_free(packed_cell_t *cell)
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 @@ clean_cell_pool(void)
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