Skip to content

Commit

Permalink
perf util: Fix do_read() to fail on EOF instead of busy-looping
Browse files Browse the repository at this point in the history
While toying with perf, I've noticed that perf record can
easily enter a busy loop when doing something as silly as:

    $ perf record -A ls

Yeah, do_read here really wants to read a known size, not being
able to should die(), not busy-loop ;)

That was the cause for the bug.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Pierre Habouzit authored and Ingo Molnar committed Aug 9, 2009
1 parent ae07b63 commit 7eac7e9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ static void do_read(int fd, void *buf, size_t size)

if (ret < 0)
die("failed to read");
if (ret == 0)
die("failed to read: missing data");

size -= ret;
buf += ret;
Expand Down

0 comments on commit 7eac7e9

Please sign in to comment.