* [TINYCOMPRESS][PATCH] compress: compress_wait() must return error if timed out
@ 2013-10-22 10:51 Richard Fitzgerald
2013-11-12 5:01 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2013-10-22 10:51 UTC (permalink / raw)
To: vinod.koul; +Cc: alsa-devel, pierre-louis.bossart, elaurent
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>
---
compress.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/compress.c b/compress.c
index 5cd0966..d1a2283 100644
--- a/compress.c
+++ b/compress.c
@@ -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");
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [TINYCOMPRESS][PATCH] compress: compress_wait() must return error if timed out
2013-10-22 10:51 [TINYCOMPRESS][PATCH] compress: compress_wait() must return error if timed out Richard Fitzgerald
@ 2013-11-12 5:01 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2013-11-12 5:01 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: alsa-devel, pierre-louis.bossart, elaurent
On Tue, Oct 22, 2013 at 11:51:58AM +0100, Richard Fitzgerald wrote:
> 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.
Applied, thanks
--
~Vinod
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> ---
> compress.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/compress.c b/compress.c
> index 5cd0966..d1a2283 100644
> --- a/compress.c
> +++ b/compress.c
> @@ -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");
> }
>
> --
> 1.7.2.5
>
--
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-12 5:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-22 10:51 [TINYCOMPRESS][PATCH] compress: compress_wait() must return error if timed out Richard Fitzgerald
2013-11-12 5:01 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).