perf util: Fix do_read() to fail on EOF instead of busy-looping
authorPierre Habouzit <pierre.habouzit@intersec.com>
Fri, 7 Aug 2009 12:16:00 +0000 (14:16 +0200)
committerIngo Molnar <mingo@elte.hu>
Sun, 9 Aug 2009 10:54:39 +0000 (12:54 +0200)
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>
tools/perf/util/header.c

index 95a44bcfc2dc5c7042f57dfe3ed49e6d5b1398a2..b92a457ca32e2eb156f8f9f3311e281579171a99 100644 (file)
@@ -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;