From 975bee12a871a4f09def1b7c9069d5ae1f766d2c Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Mon, 26 Aug 2013 23:26:43 +0200 Subject: [PATCH] fix ringbuffer size decrease --- pdns/statbag.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/pdns/statbag.cc b/pdns/statbag.cc index 83421ff75f..430c048299 100644 --- a/pdns/statbag.cc +++ b/pdns/statbag.cc @@ -189,26 +189,28 @@ void StatRing::resize(unsigned int newsize) return; Lock l(d_lock); - if(newsize>d_size) { - d_size=newsize; - d_items.resize(d_size); - return; - } - // this is the hard part, shrink - int startpos=d_pos-newsize; - int rpos; - vectornewring; - for(unsigned int i=startpos;inewsize) + startpos=d_pos-newsize; + + vectornewring; + for(unsigned int i=startpos;id_size) { + d_size=newsize; + d_items.resize(d_size); + } } + StatRing::~StatRing() { // do not clean up d_lock, it is shared -- 2.47.2