summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-05-08 17:37:00 +0530
committerVijay Bellur <vbellur@redhat.com>2013-05-31 01:48:35 -0700
commitafd669d6bde01020259ec57298c8335bc2542e4a (patch)
treed633983051283977a2d8914e98c5f0ec7a1541a0 /libglusterfs/src
parent8b65fa6575de57fc5c5a5e7db98eebfd2a3aa18f (diff)
statedump: Print entries in cb buffer in FIFO order
Currently cb buffer was being printed in LIFO order, which is was against the percieved notion of logs having older entries printed before newer entries in the state dumps. Re-did the loop to prevent crash as when w_index == 0, we would access cb[w_index - 1]. Change-Id: Idd085f73fa6937e506a2a1925e42fbcfd2d9bb1c BUG: 966847 Signed-off-by: shishir gowda <sgowda@redhat.com> Reviewed-on: http://review.gluster.org/4968 Reviewed-by: Santosh Pradhan <spradhan@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-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++) {