diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2010-11-12 03:04:07 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2010-11-12 03:04:07 -0800 |
commit | 81affe194905147f8e7692818dad786d3421f9a7 (patch) | |
tree | c8e3838ffa7d9bb2f8676f1581759437a70c7d8f /src/or/buffers.c | |
parent | 0a38358210df95f29fb7cfbb6ce67509b988ab4a (diff) | |
download | tor-81affe194905147f8e7692818dad786d3421f9a7.tar.gz tor-81affe194905147f8e7692818dad786d3421f9a7.zip |
Move the original log_info call out of the core of buf_shrink_freelists.
Sending a log message to a control port can cause Tor to allocate a buffer,
thereby changing the length of the freelist behind buf_shrink_freelists's back,
thereby causing an assertion to fail.
Fixes bug #1125.
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 571f86de1f..5b53d12f80 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -259,12 +259,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,6 +289,9 @@ 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]); |