summaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-13 09:52:07 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 12:48:20 -0500
commit9a07ec751ff73062b958a8fc9f8437bed72e144c (patch)
treef603ecc2eed23118c7e848f0a80d0b00a665e262 /src/or/relay.c
parent52d222aafbc21d674624fdd4c8fc834a40af69c7 (diff)
downloadtor-9a07ec751ff73062b958a8fc9f8437bed72e144c.tar.gz
tor-9a07ec751ff73062b958a8fc9f8437bed72e144c.zip
Refactor OOM-handling functions for more testability
This patch splits out some of the functions in OOM handling so that it's easier to check them without involving the rest of Tor or requiring that the circuits be "wired up".
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index 041a9e8b5c..dbc1710594 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -2199,12 +2199,19 @@ packed_cell_mem_cost(void)
return sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD;
}
+/** DOCDOC */
+STATIC size_t
+cell_queues_get_total_allocation(void)
+{
+ return total_cells_allocated * packed_cell_mem_cost();
+}
+
/** Check whether we've got too much space used for cells. If so,
* call the OOM handler and return 1. Otherwise, return 0. */
-static int
+STATIC int
cell_queues_check_size(void)
{
- size_t alloc = total_cells_allocated * packed_cell_mem_cost();
+ size_t alloc = cell_queues_get_total_allocation();
alloc += buf_get_total_allocation();
if (alloc >= get_options()->MaxMemInQueues) {
circuits_handle_oom(alloc);