summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorVenkatesh Somyajulu <vsomyaju@redhat.com>2013-06-12 16:59:13 +0530
committerAnand Avati <avati@redhat.com>2013-06-13 18:30:22 -0700
commit77e6caa440fb27d97fc9c6330c3598763c2351f5 (patch)
treebfd7abfd2ea2902e5aad030c12850f2ce8aed424 /libglusterfs
parent4ec4ae08c346c3e75c013bbf0529b3d7dd9a60c0 (diff)
libglusterfs: Fix circular buffer to dump entries if count is less than 1024
Problem: To dump the values present in the circular buffer, index always moves from current index to used_len. But if circular buffer is not completely filled even once then next index to be filled and used length value are always same which means it will never dump any value. Fix: Modified the logic of buffer traversing to dump values so that it will still maintain FIFO and cover both the cases where buffer is either partially filled or being used more than once. Change-Id: If73a5e481cca1751d57aba1136c2d25d23ce073c BUG: 972459 Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com> Reviewed-on: http://review.gluster.org/5197 Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/circ-buff.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libglusterfs/src/circ-buff.c b/libglusterfs/src/circ-buff.c
index d3d740a414d..a48c9287984 100644
--- a/libglusterfs/src/circ-buff.c
+++ b/libglusterfs/src/circ-buff.c
@@ -50,7 +50,7 @@ __cb_add_entry_buffer (buffer_t *buffer, void *item)
gf_log_callingfn ("", GF_LOG_WARNING, "getting time of"
"the day failed");
buffer->w_index++;
- buffer->w_index %= buffer->size_buffer - 1;
+ buffer->w_index %= buffer->size_buffer;
//used_buffer size cannot be greater than the total buffer size
if (buffer->used_len < buffer->size_buffer)
@@ -90,21 +90,35 @@ void
cb_buffer_dump (buffer_t *buffer, void *data,
int (fn) (circular_buffer_t *buffer, void *data))
{
- int i = 0;
+ int index = 0;
circular_buffer_t *entry = NULL;
int entries = 0;
+ int ul = 0;
+ int w_ind = 0;
+ int size_buff = 0;
+ int i = 0;
+
+ ul = buffer->used_len;
+ w_ind = buffer->w_index;
+ size_buff = buffer->size_buffer;
pthread_mutex_lock (&buffer->lock);
{
if (buffer->use_once == _gf_false) {
- i = buffer->w_index;
+ index = (size_buff + (w_ind - ul))%size_buff;
for (entries = 0; entries < buffer->used_len;
entries++) {
- entry = buffer->cb[i];
+ entry = buffer->cb[index];
if (entry)
fn (entry, data);
- i++;
- i %= buffer->size_buffer;
+ else
+ gf_log_callingfn ("", GF_LOG_WARNING,
+ "Null entry in "
+ "circular buffer at "
+ "index %d.", index);
+
+ index++;
+ index %= buffer->size_buffer;
}
} else {
for (i = 0; i < buffer->used_len ; i++) {