diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2010-11-12 00:21:03 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2010-11-12 02:34:51 -0800 |
commit | 6d2e02d79bf3cbd5d35fd65068485520cd6ef84b (patch) | |
tree | 3079bbdf647ceda2bc03a15999801d23e7cb244a | |
parent | 5beb8ee4e1889346dc9bec5f866b14809a2d6983 (diff) | |
download | tor-6d2e02d79bf3cbd5d35fd65068485520cd6ef84b.tar tor-6d2e02d79bf3cbd5d35fd65068485520cd6ef84b.tar.gz |
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.
-rw-r--r-- | src/or/buffers.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 09ccb7cb0..e835c615e 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -269,16 +269,12 @@ buf_shrink_freelists(int free_all) int n_to_free = free_all ? freelists[i].cur_length : (freelists[i].lowest_length - slack); int n_to_skip = freelists[i].cur_length - n_to_free; + int orig_length = freelists[i].cur_length; 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: length %d, " - "keeping %d, dropping %d.", - (int)freelists[i].alloc_size, freelists[i].cur_length, - n_to_skip, n_to_free); - tor_assert(n_to_skip + n_to_free == freelists[i].cur_length); while (n_to_skip) { if (! (*chp)->next) { log_warn(LD_BUG, "I wanted to skip %d chunks in the freelist for " @@ -313,6 +309,10 @@ 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: original " + "length %d, kept %d, dropped %d.", + (int)freelists[i].alloc_size, orig_length, + orig_n_to_skip, orig_n_to_free); } freelists[i].lowest_length = freelists[i].cur_length; assert_freelist_ok(&freelists[i]); |