From cb131836aeae75fc8735fc91d3ca24cb208ac054 Mon Sep 17 00:00:00 2001 From: Danila Shtan Date: Wed, 12 Feb 2014 15:42:46 +0500 Subject: [PATCH] remove extra bit in bitmap_pos optimisation looks like it was added because there was an error in counting last_byte_bit position in cache_mark_blocks() --- core/cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/cache.c b/core/cache.c index bda69c7e..cc84163d 100644 --- a/core/cache.c +++ b/core/cache.c @@ -681,11 +681,11 @@ int uwsgi_cache_set2(struct uwsgi_cache *uc, char *key, uint16_t keylen, char *v // mark used blocks; uint64_t needed_blocks = cache_mark_blocks(uc, uci->first_block, vallen); // optimize the scan - if (uc->blocks_bitmap_pos + (needed_blocks+1) > uc->blocks) { + if (uc->blocks_bitmap_pos + needed_blocks > uc->blocks) { uc->blocks_bitmap_pos = 0; } else { - uc->blocks_bitmap_pos = uci->first_block + needed_blocks + 1; + uc->blocks_bitmap_pos = uci->first_block + needed_blocks; } } if (expires && !(flags & UWSGI_CACHE_FLAG_ABSEXPIRE)) { @@ -773,11 +773,11 @@ int uwsgi_cache_set2(struct uwsgi_cache *uc, char *key, uint16_t keylen, char *v // mark used blocks; uint64_t needed_blocks = cache_mark_blocks(uc, uci->first_block, vallen); // optimize the scan - if (uc->blocks_bitmap_pos + (needed_blocks+1) > uc->blocks) { + if (uc->blocks_bitmap_pos + needed_blocks > uc->blocks) { uc->blocks_bitmap_pos = 0; } else { - uc->blocks_bitmap_pos = uci->first_block + needed_blocks + 1; + uc->blocks_bitmap_pos = uci->first_block + needed_blocks; } // unmark the old blocks cache_unmark_blocks(uc, uci->first_block, uci->valsize);