diff options
author | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> | 2013-10-22 11:51:58 +0100 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-03-05 13:49:37 -0800 |
commit | d848221e947b4a71fe47423c60461b0a031aabc8 (patch) | |
tree | 1b192aa077560200400b7247f04360befb9f92c4 | |
parent | a85e245a09c028d36cbf04f233be10bc583691f5 (diff) | |
download | tinycompress-kitkat-mr2-release.tar.gz |
compress: compress_wait() must return error if timed outandroid-4.4w_r1android-4.4.4_r2.0.1android-4.4.4_r2android-4.4.4_r1.0.1android-4.4.4_r1android-4.4.3_r1.1.0.1android-4.4.3_r1.1android-4.4.3_r1.0.1android-4.4.3_r1kitkat-wearkitkat-mr2.2-releasekitkat-mr2.1-releasekitkat-mr2-releasekitkat-dev
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.
Bug: 12823671.
Change-Id: I5d05ef837d9e41e5155550aab8f94f888251dc37
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r-- | compress.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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"); } |