summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/circ-buff.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/circ-buff.c')
-rw-r--r--libglusterfs/src/circ-buff.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libglusterfs/src/circ-buff.c b/libglusterfs/src/circ-buff.c
index 65bbd5d45c7..d3d740a414d 100644
--- a/libglusterfs/src/circ-buff.c
+++ b/libglusterfs/src/circ-buff.c
@@ -97,15 +97,14 @@ cb_buffer_dump (buffer_t *buffer, void *data,
pthread_mutex_lock (&buffer->lock);
{
if (buffer->use_once == _gf_false) {
- for (i = (buffer->w_index - 1) ; entries <
- buffer->used_len ; entries++) {
+ i = buffer->w_index;
+ for (entries = 0; entries < buffer->used_len;
+ entries++) {
entry = buffer->cb[i];
if (entry)
fn (entry, data);
- if (0 == i)
- i = buffer->used_len - 1;
- else
- i = (i - 1) % (buffer->used_len - 1);
+ i++;
+ i %= buffer->size_buffer;
}
} else {
for (i = 0; i < buffer->used_len ; i++) {