aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug11258
-rw-r--r--src/or/buffers.c9
2 files changed, 14 insertions, 3 deletions
diff --git a/changes/bug1125 b/changes/bug1125
new file mode 100644
index 0000000000..1331246a14
--- /dev/null
+++ b/changes/bug1125
@@ -0,0 +1,8 @@
+ o Major bugfixes
+ - Do not log messages to the controller while shrinking buffer
+ freelists. Doing so would sometimes make the controller
+ connection try to allocate a buffer chunk, which would mess
+ up the internals of the freelist and cause an assertion
+ failure. Fixes bug 1125; fixed by Robert Ransom. Bugfix on
+ Tor 0.2.0.16-alpha.
+
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 571f86de1f..b96b82de5a 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -251,6 +251,7 @@ buf_shrink_freelists(int free_all)
{
#ifdef ENABLE_BUF_FREELISTS
int i;
+ disable_control_logging();
for (i = 0; freelists[i].alloc_size; ++i) {
int slack = freelists[i].slack;
assert_freelist_ok(&freelists[i]);
@@ -259,12 +260,10 @@ buf_shrink_freelists(int free_all)
(freelists[i].lowest_length - slack);
int n_to_skip = freelists[i].cur_length - n_to_free;
int orig_n_to_free = n_to_free, n_freed=0;
+ int orig_n_to_skip = n_to_skip;
int new_length = n_to_skip;
chunk_t **chp = &freelists[i].head;
chunk_t *chunk;
- log_info(LD_MM, "Cleaning freelist for %d-byte chunks: keeping %d, "
- "dropping %d.",
- (int)freelists[i].alloc_size, n_to_skip, n_to_free);
while (n_to_skip) {
tor_assert((*chp)->next);
chp = &(*chp)->next;
@@ -291,10 +290,14 @@ buf_shrink_freelists(int free_all)
}
// tor_assert(!n_to_free);
freelists[i].cur_length = new_length;
+ log_info(LD_MM, "Cleaned freelist for %d-byte chunks: kept %d, "
+ "dropped %d.",
+ (int)freelists[i].alloc_size, orig_n_to_skip, orig_n_to_free);
}
freelists[i].lowest_length = freelists[i].cur_length;
assert_freelist_ok(&freelists[i]);
}
+ enable_control_logging();
#else
(void) free_all;
#endif