commit 5246e8f99255b376ded3d90b3c7a345c4748e68c
Author: cypherpunks <cypherpunks(a)torproject.org>
Date: Sat Feb 21 17:18:20 2015 -0500
Remove lingering mempool code
---
configure.ac | 11 --------
src/or/main.c | 8 ------
src/or/relay.c | 62 +++-----------------------------------------
src/or/relay.h | 5 ----
src/test/test.c | 3 ---
src/test/test_cell_queue.c | 16 ------------
src/test/test_channel.c | 30 ---------------------
src/test/test_circuitmux.c | 7 -----
src/test/test_oom.c | 16 ------------
src/test/test_relay.c | 8 ------
src/test/test_util.c | 3 ---
11 files changed, 3 insertions(+), 166 deletions(-)
diff --git a/configure.ac b/configure.ac
index 803ab3c..aaad11f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,17 +59,6 @@ if test "$enable_system_torrc" = "no"; then
[Defined if we're not going to look for a torrc in SYSCONF])
fi
-if test x$enable_buf_freelists = xyes; then
- AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
- [Defined if we try to use freelists for buffer RAM chunks])
-fi
-
-AM_CONDITIONAL(USE_MEMPOOLS, test x$enable_mempools = xyes)
-if test x$enable_mempools = xyes; then
- AC_DEFINE(ENABLE_MEMPOOLS, 1,
- [Defined if we try to use mempools for cells being relayed])
-fi
-
AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
if test x$enable_instrument_downloads = xyes; then
AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
diff --git a/src/or/main.c b/src/or/main.c
index 09144cb..2ef7a74 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1987,11 +1987,6 @@ do_main_loop(void)
}
}
-#ifdef ENABLE_MEMPOOLS
- /* Set up the packed_cell_t memory pool. */
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
/* Set up our buckets */
connection_bucket_init();
#ifndef USE_BUFFEREVENTS
@@ -2646,9 +2641,6 @@ tor_free_all(int postfork)
router_free_all();
policies_free_all();
}
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
if (!postfork) {
tor_tls_free_all();
#ifndef _WIN32
diff --git a/src/or/relay.c b/src/or/relay.c
index c83d924..50eaab8 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -26,9 +26,6 @@
#include "control.h"
#include "geoip.h"
#include "main.h"
-#ifdef ENABLE_MEMPOOLS
-#include "mempool.h"
-#endif
#include "networkstatus.h"
#include "nodelist.h"
#include "onion.h"
@@ -2252,62 +2249,12 @@ circuit_consider_sending_sendme(circuit_t *circ, crypt_path_t *layer_hint)
/** The total number of cells we have allocated. */
static size_t total_cells_allocated = 0;
-#ifdef ENABLE_MEMPOOLS
-/** A memory pool to allocate packed_cell_t objects. */
-static mp_pool_t *cell_pool = NULL;
-
-/** Allocate structures to hold cells. */
-void
-init_cell_pool(void)
-{
- tor_assert(!cell_pool);
- cell_pool = mp_pool_new(sizeof(packed_cell_t), 128*1024);
-}
-
-/** Free all storage used to hold cells (and insertion times/commands if we
- * measure cell statistics and/or if CELL_STATS events are enabled). */
-void
-free_cell_pool(void)
-{
- /* Maybe we haven't called init_cell_pool yet; need to check for it. */
- if (cell_pool) {
- mp_pool_destroy(cell_pool);
- cell_pool = NULL;
- }
-}
-
-/** Free excess storage in cell pool. */
-void
-clean_cell_pool(void)
-{
- tor_assert(cell_pool);
- mp_pool_clean(cell_pool, 0, 1);
-}
-
-#define relay_alloc_cell() \
- mp_pool_get(cell_pool)
-#define relay_free_cell(cell) \
- mp_pool_release(cell)
-
-#define RELAY_CELL_MEM_COST (sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD)
-
-#else /* !ENABLE_MEMPOOLS case */
-
-#define relay_alloc_cell() \
- tor_malloc_zero(sizeof(packed_cell_t))
-#define relay_free_cell(cell) \
- tor_free(cell)
-
-#define RELAY_CELL_MEM_COST (sizeof(packed_cell_t))
-
-#endif /* ENABLE_MEMPOOLS */
-
/** Release storage held by <b>cell</b>. */
static INLINE void
packed_cell_free_unchecked(packed_cell_t *cell)
{
--total_cells_allocated;
- relay_free_cell(cell);
+ tor_free(cell);
}
/** Allocate and return a new packed_cell_t. */
@@ -2315,7 +2262,7 @@ STATIC packed_cell_t *
packed_cell_new(void)
{
++total_cells_allocated;
- return relay_alloc_cell();
+ return tor_malloc_zero(sizeof(packed_cell_t));
}
/** Return a packed cell used outside by channel_t lower layer */
@@ -2344,9 +2291,6 @@ dump_cell_pool_usage(int severity)
tor_log(severity, LD_MM,
"%d cells allocated on %d circuits. %d cells leaked.",
n_cells, n_circs, (int)total_cells_allocated - n_cells);
-#ifdef ENABLE_MEMPOOLS
- mp_pool_log_status(cell_pool, severity);
-#endif
}
/** Allocate a new copy of packed <b>cell</b>. */
@@ -2426,7 +2370,7 @@ cell_queue_pop(cell_queue_t *queue)
size_t
packed_cell_mem_cost(void)
{
- return RELAY_CELL_MEM_COST;
+ return sizeof(packed_cell_t);
}
/** DOCDOC */
diff --git a/src/or/relay.h b/src/or/relay.h
index cdc2a9a..a4f583d 100644
--- a/src/or/relay.h
+++ b/src/or/relay.h
@@ -42,11 +42,6 @@ extern uint64_t stats_n_data_bytes_packaged;
extern uint64_t stats_n_data_cells_received;
extern uint64_t stats_n_data_bytes_received;
-#ifdef ENABLE_MEMPOOLS
-void init_cell_pool(void);
-void free_cell_pool(void);
-void clean_cell_pool(void);
-#endif /* ENABLE_MEMPOOLS */
void dump_cell_pool_usage(int severity);
size_t packed_cell_mem_cost(void);
diff --git a/src/test/test.c b/src/test/test.c
index 6c7db4e..0524a69 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -49,9 +49,6 @@ double fabs(double x);
#include "rendcommon.h"
#include "test.h"
#include "torgzip.h"
-#ifdef ENABLE_MEMPOOLS
-#include "mempool.h"
-#endif
#include "memarea.h"
#include "onion.h"
#include "onion_ntor.h"
diff --git a/src/test/test_cell_queue.c b/src/test/test_cell_queue.c
index effd316..ed34df2 100644
--- a/src/test/test_cell_queue.c
+++ b/src/test/test_cell_queue.c
@@ -16,10 +16,6 @@ test_cq_manip(void *arg)
cell_t cell;
(void) arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
cell_queue_init(&cq);
tt_int_op(cq.n, OP_EQ, 0);
@@ -99,10 +95,6 @@ test_cq_manip(void *arg)
packed_cell_free(pc_tmp);
cell_queue_clear(&cq);
-
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
}
static void
@@ -114,10 +106,6 @@ test_circuit_n_cells(void *arg)
(void)arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
pc1 = packed_cell_new();
pc2 = packed_cell_new();
pc3 = packed_cell_new();
@@ -144,10 +132,6 @@ test_circuit_n_cells(void *arg)
done:
circuit_free(TO_CIRCUIT(or_c));
circuit_free(TO_CIRCUIT(origin_c));
-
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
}
struct testcase_t cell_queue_tests[] = {
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index 99633a4..6cf6649 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -650,10 +650,6 @@ test_channel_flush(void *arg)
(void)arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
ch = new_fake_channel();
tt_assert(ch);
@@ -695,9 +691,6 @@ test_channel_flush(void *arg)
done:
tor_free(ch);
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
return;
}
@@ -715,10 +708,6 @@ test_channel_flushmux(void *arg)
(void)arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
/* Install mocks we need for this test */
MOCK(channel_flush_from_first_active_circuit,
chan_test_channel_flush_from_first_active_circuit_mock);
@@ -778,10 +767,6 @@ test_channel_flushmux(void *arg)
test_chan_accept_cells = 0;
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
return;
}
@@ -1300,10 +1285,6 @@ test_channel_queue_impossible(void *arg)
(void)arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
ch = new_fake_channel();
tt_assert(ch);
@@ -1430,9 +1411,6 @@ test_channel_queue_impossible(void *arg)
done:
free_fake_channel(ch);
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
/*
* Doing that meant that we couldn't correctly adjust the queue size
@@ -1575,10 +1553,6 @@ test_channel_write(void *arg)
(void)arg;
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
packed_cell = packed_cell_new();
tt_assert(packed_cell);
@@ -1675,10 +1649,6 @@ test_channel_write(void *arg)
packed_cell = NULL;
tt_assert(test_cells_written == old_count);
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
done:
free_fake_channel(ch);
tor_free(var_cell);
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index 2a2a7ba..6d93731 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -43,9 +43,6 @@ test_cmux_destroy_cell_queue(void *arg)
tor_libevent_initialize(&cfg);
scheduler_init();
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
(void) arg;
cmux = circuitmux_alloc();
@@ -82,10 +79,6 @@ test_cmux_destroy_cell_queue(void *arg)
circuitmux_free(cmux);
channel_free(ch);
packed_cell_free(pc);
-
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
}
struct testcase_t circuitmux_tests[] = {
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index 28b4c04..41cfcdb 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -13,9 +13,6 @@
#include "compat_libevent.h"
#include "connection.h"
#include "config.h"
-#ifdef ENABLE_MEMPOOLS
-#include "mempool.h"
-#endif
#include "relay.h"
#include "test.h"
@@ -143,10 +140,6 @@ test_oom_circbuf(void *arg)
MOCK(circuit_mark_for_close_, circuit_mark_for_close_dummy_);
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
/* Far too low for real life. */
options->MaxMemInQueues = 256*packed_cell_mem_cost();
options->CellStatistics = 0;
@@ -164,13 +157,8 @@ test_oom_circbuf(void *arg)
tor_gettimeofday_cache_set(&tv);
c2 = dummy_or_circuit_new(20, 20);
-#ifdef ENABLE_MEMPOOLS
- tt_int_op(packed_cell_mem_cost(), OP_EQ,
- sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD);
-#else
tt_int_op(packed_cell_mem_cost(), OP_EQ,
sizeof(packed_cell_t));
-#endif /* ENABLE_MEMPOOLS */
tt_int_op(cell_queues_get_total_allocation(), OP_EQ,
packed_cell_mem_cost() * 70);
tt_int_op(cell_queues_check_size(), OP_EQ, 0); /* We are still not OOM */
@@ -242,10 +230,6 @@ test_oom_streambuf(void *arg)
MOCK(circuit_mark_for_close_, circuit_mark_for_close_dummy_);
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
/* Far too low for real life. */
options->MaxMemInQueues = 81*packed_cell_mem_cost() + 4096 * 34;
options->CellStatistics = 0;
diff --git a/src/test/test_relay.c b/src/test/test_relay.c
index 2144ef3..6081956 100644
--- a/src/test/test_relay.c
+++ b/src/test/test_relay.c
@@ -60,11 +60,6 @@ test_relay_append_cell_to_circuit_queue(void *arg)
(void)arg;
- /* We'll need the cell pool for append_cell_to_circuit_queue() to work */
-#ifdef ENABLE_MEMPOOLS
- init_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
-
/* Make fake channels to be nchan and pchan for the circuit */
nchan = new_fake_channel();
tt_assert(nchan);
@@ -119,9 +114,6 @@ test_relay_append_cell_to_circuit_queue(void *arg)
tor_free(orcirc);
free_fake_channel(nchan);
free_fake_channel(pchan);
-#ifdef ENABLE_MEMPOOLS
- free_cell_pool();
-#endif /* ENABLE_MEMPOOLS */
return;
}
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 9939bf4..51e9e76 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -4338,9 +4338,6 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(pow2),
UTIL_LEGACY(gzip),
UTIL_LEGACY(datadir),
-#ifdef ENABLE_MEMPOOLS
- UTIL_LEGACY(mempool),
-#endif
UTIL_LEGACY(memarea),
UTIL_LEGACY(control_formats),
UTIL_LEGACY(mmap),