]> git.alsa-project.org Git - tinycompress.git/commitdiff
compress: compress_wait() must return error if timed out
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Tue, 22 Oct 2013 10:51:58 +0000 (11:51 +0100)
committerVinod Koul <vinod.koul@intel.com>
Tue, 12 Nov 2013 04:59:39 +0000 (10:29 +0530)
The caller must be certain that a return of 0 really means
that compress is ready for more data, so when poll() returns
0 for a timeout we must report that as an error.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
compress.c

index 5cd0966a51a5eba56049cda64d04b8fdb4054c97..d1a22831402d6234a8bb43f6f78abdeea5fe2548 100644 (file)
@@ -616,15 +616,17 @@ int compress_wait(struct compress *compress, int timeout_ms)
        fds.events = POLLOUT | POLLIN;
 
        ret = poll(&fds, 1, timeout_ms);
-       if (fds.revents & POLLERR) {
-               return oops(compress, EIO, "poll returned error!");
+       if (ret > 0) {
+               if (fds.revents & POLLERR)
+                       return oops(compress, EIO, "poll returned error!");
+               if (fds.revents & (POLLOUT | POLLIN))
+                       return 0;
        }
-       /* A pause will cause -EBADFD or zero. */
-       if ((ret < 0) && (ret != -EBADFD))
+       if (ret == 0)
+               return oops(compress, ETIME, "poll timed out");
+       if (ret < 0)
                return oops(compress, errno, "poll error");
-       if (fds.revents & (POLLOUT | POLLIN)) {
-               return 0;
-       }
-       return ret;
+
+       return oops(compress, EIO, "poll signalled unhandled event");
 }