From db7e0552967aed47a6310122869ee261cd3f9162 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 31 Jan 2006 09:24:29 +0100 Subject: [PATCH] [PATCH] blkparse: be sure to propagate read_data() error all the way back --- blkparse.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/blkparse.c b/blkparse.c index 8a90362..4a14f32 100644 --- a/blkparse.c +++ b/blkparse.c @@ -1725,8 +1725,10 @@ static int read_data(int fd, void *buffer, int bytes, int block, int *fdblock) if (!ret) return 1; else if (ret < 0) { - if (errno != EAGAIN) + if (errno != EAGAIN) { perror("read"); + return -1; + } /* * never do partial reads. we can return if we @@ -1755,15 +1757,18 @@ static int read_events(int fd, int always_block, int *fdblock) while (!is_done() && events < rb_batch) { struct blk_io_trace *bit; struct trace *t; - int pdu_len, should_block; + int pdu_len, should_block, ret; __u32 magic; bit = bit_alloc(); should_block = !events || always_block; - if (read_data(fd, bit, sizeof(*bit), should_block, fdblock)) { + ret = read_data(fd, bit, sizeof(*bit), should_block, fdblock); + if (ret) { bit_free(bit); + if (!events && ret < 0) + events = ret; break; } @@ -1886,7 +1891,7 @@ static int do_file(void) continue; events = read_events(pci->fd, 1, &pci->fdblock); - if (!events) { + if (events <= 0) { cpu_mark_offline(pdi, pci->cpu); close(pci->fd); pci->fd = -1; @@ -1929,7 +1934,7 @@ static int do_stdin(void) } fdblock = -1; - while ((events = read_events(fd, 0, &fdblock)) != 0) { + while ((events = read_events(fd, 0, &fdblock)) > 0) { smallest_seq_read = -1U; -- 2.25.1