[PATCH] blktrace: better poll fix, just return every x msec instead
authorJens Axboe <axboe@suse.de>
Wed, 18 Jan 2006 19:29:14 +0000 (20:29 +0100)
committerJens Axboe <axboe@suse.de>
Wed, 18 Jan 2006 19:29:14 +0000 (20:29 +0100)
blktrace.c

index a73195ca5ed4782858eecfa77128c3424f979a06..4a1019c20d1afba69a4193cf2f5ae65d4b452c55 100644 (file)
@@ -272,33 +272,24 @@ static void wait_for_data(struct thread_information *tip)
 {
        struct pollfd pfd = { .fd = tip->fd, .events = POLLIN };
 
-       while (!is_done()) {
-               poll(&pfd, 1, 10);
-               if (pfd.revents & POLLIN)
-                       break;
-       }
+       poll(&pfd, 1, 10);
 }
 
 static int __read_data(struct thread_information *tip, void *buf, int len,
                       int block)
 {
-       int ret = 0, waited = 0;
+       int ret = 0;
 
-       while (!is_done() || waited) {
+       while (!is_done()) {
                ret = read(tip->fd, buf, len);
-               waited = 0;
                fprintf(stderr, "got %d, block %d\n", ret, block);
                if (ret > 0)
                        break;
                else if (!ret) {
                        if (!block)
                                break;
-                       /*
-                        * the waited logic is needed, because the relayfs
-                        * poll works on a sub-buffer granularity
-                        */
+
                        wait_for_data(tip);
-                       waited = 1;
                } else {
                        if (errno != EAGAIN) {
                                perror(tip->fn);
@@ -312,7 +303,6 @@ static int __read_data(struct thread_information *tip, void *buf, int len,
                        }
 
                        wait_for_data(tip);
-                       waited = 0;
                }
        }