diff options
-rw-r--r-- | changes/bug11476 | 5 | ||||
-rw-r--r-- | changes/bug12064_part1 | 4 | ||||
-rw-r--r-- | changes/bug12064_part2 | 5 | ||||
-rw-r--r-- | changes/stats_not_status | 4 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | doc/tor.1.txt | 12 | ||||
-rw-r--r-- | src/common/include.am | 16 | ||||
-rw-r--r-- | src/or/circuitlist.c | 2 | ||||
-rw-r--r-- | src/or/config.c | 31 | ||||
-rwxr-xr-x | src/or/control.c | 9 | ||||
-rw-r--r-- | src/or/control.h | 1 | ||||
-rw-r--r-- | src/or/main.c | 40 | ||||
-rw-r--r-- | src/or/relay.c | 31 | ||||
-rw-r--r-- | src/or/relay.h | 2 | ||||
-rw-r--r-- | src/or/rendservice.c | 25 | ||||
-rw-r--r-- | src/or/rendservice.h | 1 | ||||
-rw-r--r-- | src/test/test.c | 2 | ||||
-rw-r--r-- | src/test/test_cell_queue.c | 10 | ||||
-rw-r--r-- | src/test/test_circuitmux.c | 4 | ||||
-rw-r--r-- | src/test/test_oom.c | 13 | ||||
-rw-r--r-- | src/test/test_util.c | 8 |
21 files changed, 197 insertions, 41 deletions
diff --git a/changes/bug11476 b/changes/bug11476 new file mode 100644 index 000000000..cb3d217cd --- /dev/null +++ b/changes/bug11476 @@ -0,0 +1,5 @@ + o Bugfixes: + - Add configure options controlling allocator tricks like mempools and + freelists, and turn them off by default; on most platforms malloc is + reasonable enough for this not to be necessary, and a similar feature + in OpenSSL exacerbated Heartbleed. Fixes bug #11476. diff --git a/changes/bug12064_part1 b/changes/bug12064_part1 new file mode 100644 index 000000000..b40b64aa3 --- /dev/null +++ b/changes/bug12064_part1 @@ -0,0 +1,4 @@ + o Minor bugfixes (seccomp sandbox): + - Avoid warnings when running with sandboxing and node statistics + enabled at the same time. + Fixes part of 12064; bugfix on 0.2.5.1-alpha. Patch from Michael Wolf. diff --git a/changes/bug12064_part2 b/changes/bug12064_part2 new file mode 100644 index 000000000..4fa86a641 --- /dev/null +++ b/changes/bug12064_part2 @@ -0,0 +1,5 @@ + o Minor bugfixes (seccomp sandbox): + - Avoid warnings when running with sandboxing enabled at the same + time as cookie authentication, hidden services or directory + authority voting. Fixes part of 12064; bugfix on 0.2.5.1-alpha. + diff --git a/changes/stats_not_status b/changes/stats_not_status new file mode 100644 index 000000000..e2bc37e5e --- /dev/null +++ b/changes/stats_not_status @@ -0,0 +1,4 @@ + o Minor bugfixes (documentation): + - Correct the documenation so that it lists the correct directories + for the stats files. (They are in a subdirectory called "stats", + not "status".) diff --git a/configure.ac b/configure.ac index d3210921e..6e9e13d76 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,9 @@ CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common" #XXXX020 We should make these enabled or not, before 0.2.0.x-final AC_ARG_ENABLE(buf-freelists, - AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM)) + AS_HELP_STRING(--enable-buf-freelists, enable freelists for buffer RAM)) +AC_ARG_ENABLE(mempools, + AS_HELP_STRING(--enable-mempools, enable mempools for relay cells)) AC_ARG_ENABLE(openbsd-malloc, AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only)) AC_ARG_ENABLE(instrument-downloads, @@ -54,10 +56,17 @@ if test "$enable_static_tor" = "yes"; then CFLAGS="$CFLAGS -static" fi -if test x$enable_buf_freelists != xno; then +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/doc/tor.1.txt b/doc/tor.1.txt index 2f97ecdb3..2d89e62b4 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -2364,27 +2364,27 @@ __DataDirectory__**/router-stability**:: router mean-time-between-failures so that authorities have a good idea of how to set their Stable flags. -__DataDirectory__**/status/dirreq-stats**:: +__DataDirectory__**/stats/dirreq-stats**:: Only used by directory caches and authorities. This file is used to collect directory request statistics. -__DataDirectory__**/status/entry-stats**:: +__DataDirectory__**/stats/entry-stats**:: Only used by servers. This file is used to collect incoming connection statistics by Tor entry nodes. -__DataDirectory__**/status/bridge-stats**:: +__DataDirectory__**/stats/bridge-stats**:: Only used by servers. This file is used to collect incoming connection statistics by Tor bridges. -__DataDirectory__**/status/exit-stats**:: +__DataDirectory__**/stats/exit-stats**:: Only used by servers. This file is used to collect outgoing connection statistics by Tor exit routers. -__DataDirectory__**/status/buffer-stats**:: +__DataDirectory__**/stats/buffer-stats**:: Only used by servers. This file is used to collect buffer usage history. -__DataDirectory__**/status/conn-stats**:: +__DataDirectory__**/stats/conn-stats**:: Only used by servers. This file is used to collect approximate connection history (number of active connections over time). diff --git a/src/common/include.am b/src/common/include.am index 7b2465cd8..61a90cd35 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -24,6 +24,14 @@ else libor_extra_source= endif +if USE_MEMPOOLS +libor_mempool_source=src/common/mempool.c +libor_mempool_header=src/common/mempool.h +else +libor_mempool_source= +libor_mempool_header= +endif + src_common_libcurve25519_donna_a_CFLAGS= if BUILD_CURVE25519_DONNA @@ -56,13 +64,13 @@ LIBOR_A_SOURCES = \ src/common/di_ops.c \ src/common/log.c \ src/common/memarea.c \ - src/common/mempool.c \ src/common/procmon.c \ src/common/util.c \ src/common/util_codedigest.c \ src/common/sandbox.c \ src/ext/csiphash.c \ - $(libor_extra_source) + $(libor_extra_source) \ + $(libor_mempool_source) LIBOR_CRYPTO_A_SOURCES = \ src/common/aes.c \ @@ -102,7 +110,6 @@ COMMONHEADERS = \ src/common/crypto_curve25519.h \ src/common/di_ops.h \ src/common/memarea.h \ - src/common/mempool.h \ src/common/linux_syscalls.inc \ src/common/procmon.h \ src/common/sandbox.h \ @@ -111,7 +118,8 @@ COMMONHEADERS = \ src/common/torint.h \ src/common/torlog.h \ src/common/tortls.h \ - src/common/util.h + src/common/util.h \ + $(libor_mempool_header) noinst_HEADERS+= $(COMMONHEADERS) diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index e5ed9c04f..6238e08e1 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -1983,7 +1983,9 @@ circuits_handle_oom(size_t current_allocation) break; } SMARTLIST_FOREACH_END(circ); +#ifdef ENABLE_MEMPOOLS clean_cell_pool(); /* In case this helps. */ +#endif /* ENABLE_MEMPOOLS */ buf_shrink_freelists(1); /* This is necessary to actually release buffer chunks. */ diff --git a/src/or/config.c b/src/or/config.c index 0f7b1d2a2..10df83975 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3722,10 +3722,22 @@ options_transition_allowed(const or_options_t *old, } if (sandbox_is_active()) { - if (! opt_streq(old->PidFile, new_val->PidFile)) { - *msg = tor_strdup("Can't change PidFile while Sandbox is active"); - return -1; - } +#define SB_NOCHANGE_STR(opt) \ + do { \ + if (! opt_streq(old->opt, new_val->opt)) { \ + *msg = tor_strdup("Can't change " #opt " while Sandbox is active"); \ + return -1; \ + } \ + } while (0) + + SB_NOCHANGE_STR(PidFile); + SB_NOCHANGE_STR(ServerDNSResolvConfFile); + SB_NOCHANGE_STR(DirPortFrontPage); + SB_NOCHANGE_STR(CookieAuthFile); + SB_NOCHANGE_STR(ExtORPortCookieAuthFile); + +#undef SB_NOCHANGE_STR + if (! config_lines_eq(old->Logs, new_val->Logs)) { *msg = tor_strdup("Can't change Logs while Sandbox is active"); return -1; @@ -3734,22 +3746,11 @@ options_transition_allowed(const or_options_t *old, *msg = tor_strdup("Can't change ConnLimit while Sandbox is active"); return -1; } - if (! opt_streq(old->ServerDNSResolvConfFile, - new_val->ServerDNSResolvConfFile)) { - *msg = tor_strdup("Can't change ServerDNSResolvConfFile" - " while Sandbox is active"); - return -1; - } if (server_mode(old) != server_mode(new_val)) { *msg = tor_strdup("Can't start/stop being a server while " "Sandbox is active"); return -1; } - if (! opt_streq(old->DirPortFrontPage, new_val->DirPortFrontPage)) { - *msg = tor_strdup("Can't change DirPortFrontPage" - " while Sandbox is active"); - return -1; - } } return 0; diff --git a/src/or/control.c b/src/or/control.c index 2865d7832..21504e685 100755 --- a/src/or/control.c +++ b/src/or/control.c @@ -160,7 +160,6 @@ static int write_stream_target_to_buf(entry_connection_t *conn, char *buf, size_t len); static void orconn_target_get_name(char *buf, size_t len, or_connection_t *conn); -static char *get_cookie_file(void); /** Given a control event code for a message event, return the corresponding * log severity. */ @@ -2944,7 +2943,7 @@ handle_control_protocolinfo(control_connection_t *conn, uint32_t len, } else { const or_options_t *options = get_options(); int cookies = options->CookieAuthentication; - char *cfile = get_cookie_file(); + char *cfile = get_controller_cookie_file_name(); char *abs_cfile; char *esc_cfile; char *methods; @@ -4639,8 +4638,8 @@ control_event_conf_changed(const smartlist_t *elements) /** Helper: Return a newly allocated string containing a path to the * file where we store our authentication cookie. */ -static char * -get_cookie_file(void) +char * +get_controller_cookie_file_name(void) { const or_options_t *options = get_options(); if (options->CookieAuthFile && strlen(options->CookieAuthFile)) { @@ -4664,7 +4663,7 @@ init_control_cookie_authentication(int enabled) return 0; } - fname = get_cookie_file(); + fname = get_controller_cookie_file_name(); retval = init_cookie_authentication(fname, "", /* no header */ AUTHENTICATION_COOKIE_LEN, &authentication_cookie, diff --git a/src/or/control.h b/src/or/control.h index 988c171d7..68a6c244d 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -85,6 +85,7 @@ int control_event_buildtimeout_set(buildtimeout_set_event_t type, int control_event_signal(uintptr_t signal); int init_control_cookie_authentication(int enabled); +char *get_controller_cookie_file_name(void); smartlist_t *decode_hashed_passwords(config_line_t *passwords); void disable_control_logging(void); void enable_control_logging(void); diff --git a/src/or/main.c b/src/or/main.c index 6f6066a93..4ac7781cd 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1524,7 +1524,9 @@ run_scheduled_events(time_t now) if (conn->inbuf) buf_shrink(conn->inbuf); }); +#ifdef ENABLE_MEMPOOL clean_cell_pool(); +#endif /* ENABLE_MEMPOOL */ buf_shrink_freelists(0); /** How often do we check buffers and pools for empty space that can be * deallocated? */ @@ -1929,8 +1931,10 @@ 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(); @@ -2547,7 +2551,9 @@ 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 @@ -2825,13 +2831,24 @@ sandbox_init_filter(void) ); { - smartlist_t *logfiles = smartlist_new(); - tor_log_get_logfile_names(logfiles); - SMARTLIST_FOREACH(logfiles, char *, logfile_name, { + smartlist_t *files = smartlist_new(); + tor_log_get_logfile_names(files); + rend_services_add_filenames_to_list(files); + SMARTLIST_FOREACH(files, char *, file_name, { /* steals reference */ - sandbox_cfg_allow_open_filename(&cfg, logfile_name); + sandbox_cfg_allow_open_filename(&cfg, file_name); }); - smartlist_free(logfiles); + smartlist_free(files); + } + + { + char *fname; + if ((fname = get_controller_cookie_file_name())) { + sandbox_cfg_allow_open_filename(&cfg, fname); + } + if ((fname = get_ext_or_auth_cookie_file_name())) { + sandbox_cfg_allow_open_filename(&cfg, fname); + } } // orport @@ -2850,6 +2867,15 @@ sandbox_init_filter(void) get_datadir_fname2("stats", "bridge-stats.tmp"), get_datadir_fname2("stats", "dirreq-stats"), get_datadir_fname2("stats", "dirreq-stats.tmp"), + get_datadir_fname2("stats", "entry-stats"), + get_datadir_fname2("stats", "entry-stats.tmp"), + get_datadir_fname2("stats", "exit-stats"), + get_datadir_fname2("stats", "exit-stats.tmp"), + get_datadir_fname2("stats", "buffer-stats"), + get_datadir_fname2("stats", "buffer-stats.tmp"), + get_datadir_fname2("stats", "conn-stats"), + get_datadir_fname2("stats", "conn-stats.tmp"), + get_datadir_fname("approved-routers"), get_datadir_fname("fingerprint"), get_datadir_fname("fingerprint.tmp"), get_datadir_fname("hashed-fingerprint"), @@ -2873,6 +2899,10 @@ sandbox_init_filter(void) RENAME_SUFFIX2("keys", "secret_onion_key.old", ".tmp"); RENAME_SUFFIX2("stats", "bridge-stats", ".tmp"); RENAME_SUFFIX2("stats", "dirreq-stats", ".tmp"); + RENAME_SUFFIX2("stats", "entry-stats", ".tmp"); + RENAME_SUFFIX2("stats", "exit-stats", ".tmp"); + RENAME_SUFFIX2("stats", "buffer-stats", ".tmp"); + RENAME_SUFFIX2("stats", "conn-stats", ".tmp"); RENAME_SUFFIX("hashed-fingerprint", ".tmp"); RENAME_SUFFIX("router-stability", ".tmp"); diff --git a/src/or/relay.c b/src/or/relay.c index f8b0deedb..5c430a6d7 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -26,7 +26,9 @@ #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" @@ -2231,9 +2233,10 @@ circuit_consider_sending_sendme(circuit_t *circ, crypt_path_t *layer_hint) #define assert_cmux_ok_paranoid(chan) #endif -/** The total number of cells we have allocated from the memory pool. */ +/** 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; @@ -2265,12 +2268,30 @@ clean_cell_pool(void) 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; - mp_pool_release(cell); + relay_free_cell(cell); } /** Allocate and return a new packed_cell_t. */ @@ -2278,7 +2299,7 @@ STATIC packed_cell_t * packed_cell_new(void) { ++total_cells_allocated; - return mp_pool_get(cell_pool); + return relay_alloc_cell(); } /** Return a packed cell used outside by channel_t lower layer */ @@ -2307,7 +2328,9 @@ 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>. */ @@ -2387,7 +2410,7 @@ cell_queue_pop(cell_queue_t *queue) size_t packed_cell_mem_cost(void) { - return sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD; + return RELAY_CELL_MEM_COST; } /** DOCDOC */ diff --git a/src/or/relay.h b/src/or/relay.h index 9c0e21c14..479d474b3 100644 --- a/src/or/relay.h +++ b/src/or/relay.h @@ -42,9 +42,11 @@ 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/or/rendservice.c b/src/or/rendservice.c index 5a81d0785..631e2a0f2 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -656,6 +656,31 @@ rend_service_load_all_keys(void) return 0; } +/** Add to <b>lst</b> every filename used by <b>s</b>. */ +static void +rend_service_add_filenames_to_list(smartlist_t *lst, const rend_service_t *s) +{ + tor_assert(lst); + tor_assert(s); + smartlist_add_asprintf(lst, "%s"PATH_SEPARATOR"private_key", + s->directory); + smartlist_add_asprintf(lst, "%s"PATH_SEPARATOR"hostname", + s->directory); + smartlist_add_asprintf(lst, "%s"PATH_SEPARATOR"client_keys", + s->directory); +} + +/** Add to <b>lst</b> every filename used by a configured hidden service */ +void +rend_services_add_filenames_to_list(smartlist_t *lst) +{ + if (!rend_service_list) + return; + SMARTLIST_FOREACH_BEGIN(rend_service_list, rend_service_t *, s) { + rend_service_add_filenames_to_list(lst, s); + } SMARTLIST_FOREACH_END(s); +} + /** Load and/or generate private keys for the hidden service <b>s</b>, * possibly including keys for client authorization. Return 0 on success, -1 * on failure. */ diff --git a/src/or/rendservice.h b/src/or/rendservice.h index 4a810eb52..e8a953665 100644 --- a/src/or/rendservice.h +++ b/src/or/rendservice.h @@ -71,6 +71,7 @@ struct rend_intro_cell_s { int num_rend_services(void); int rend_config_services(const or_options_t *options, int validate_only); int rend_service_load_all_keys(void); +void rend_services_add_filenames_to_list(smartlist_t *lst); void rend_services_introduce(void); void rend_consider_services_upload(time_t now); void rend_hsdir_routers_changed(void); diff --git a/src/test/test.c b/src/test/test.c index c96b39659..8bce9c91f 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -52,7 +52,9 @@ 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 1eac07310..92629823e 100644 --- a/src/test/test_cell_queue.c +++ b/src/test/test_cell_queue.c @@ -16,7 +16,10 @@ 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, ==, 0); @@ -96,7 +99,10 @@ 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 @@ -108,7 +114,9 @@ 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(); @@ -137,7 +145,9 @@ test_circuit_n_cells(void *arg) 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_circuitmux.c b/src/test/test_circuitmux.c index 0f592001c..b9c0436eb 100644 --- a/src/test/test_circuitmux.c +++ b/src/test/test_circuitmux.c @@ -36,7 +36,9 @@ test_cmux_destroy_cell_queue(void *arg) cell_queue_t *cq = NULL; packed_cell_t *pc = NULL; +#ifdef ENABLE_MEMPOOLS init_cell_pool(); +#endif /* ENABLE_MEMPOOLS */ (void) arg; cmux = circuitmux_alloc(); @@ -74,7 +76,9 @@ test_cmux_destroy_cell_queue(void *arg) 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 e205673be..32f4803bb 100644 --- a/src/test/test_oom.c +++ b/src/test/test_oom.c @@ -13,7 +13,9 @@ #include "compat_libevent.h" #include "connection.h" #include "config.h" +#ifdef ENABLE_MEMPOOLS #include "mempool.h" +#endif #include "relay.h" #include "test.h" @@ -131,7 +133,10 @@ test_oom_circbuf(void *arg) (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(); @@ -150,8 +155,13 @@ 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(), ==, sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD); +#else + tt_int_op(packed_cell_mem_cost(), ==, + sizeof(packed_cell_t)); +#endif /* ENABLE_MEMPOOLS */ tt_int_op(cell_queues_get_total_allocation(), ==, packed_cell_mem_cost() * 70); tt_int_op(cell_queues_check_size(), ==, 0); /* We are still not OOM */ @@ -222,7 +232,10 @@ test_oom_streambuf(void *arg) (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; diff --git a/src/test/test_util.c b/src/test/test_util.c index 65cc58a66..c7fa14118 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -12,7 +12,9 @@ #include "config.h" #include "control.h" #include "test.h" +#ifdef ENABLE_MEMPOOLS #include "mempool.h" +#endif /* ENABLE_MEMPOOLS */ #include "memarea.h" #ifdef _WIN32 @@ -1899,6 +1901,8 @@ test_util_path_is_relative(void) ; } +#ifdef ENABLE_MEMPOOLS + /** Run unittests for memory pool allocator */ static void test_util_mempool(void) @@ -1957,6 +1961,8 @@ test_util_mempool(void) mp_pool_destroy(pool); } +#endif /* ENABLE_MEMPOOLS */ + /** Run unittests for memory area allocator */ static void test_util_memarea(void) @@ -3661,7 +3667,9 @@ 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), |