All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: vinod.koul@intel.com
Cc: alsa-devel@alsa-project.org,
	pierre-louis.bossart@linux.intel.com, elaurent@google.com
Subject: [TINYCOMPRESS][PATCH 1/1] compress: Must check for POLLERR before	POLLOUT/POLLIN
Date: Thu, 29 Aug 2013 09:32:02 +0100	[thread overview]
Message-ID: <20130829083202.GA1538@opensource.wolfsonmicro.com> (raw)

In the case of error the ALSA compressed driver sets revents as
(POLLOUT | POLLWRNORM | POLLERR) or (POLLIN | POLLWRNORM | POLLERR).
So we can't assume that POLLOUT or POLLIN indicate success, we must
check for POLLERR first.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
 compress.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/compress.c b/compress.c
index 0e71c28..5cd0966 100644
--- a/compress.c
+++ b/compress.c
@@ -378,6 +378,9 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
 				return total;
 
 			ret = poll(&fds, 1, compress->max_poll_wait_ms);
+			if (fds.revents & POLLERR) {
+				return oops(compress, EIO, "poll returned error!");
+			}
 			/* A pause will cause -EBADFD or zero.
 			 * This is not an error, just stop writing */
 			if ((ret == 0) || (ret == -EBADFD))
@@ -387,9 +390,6 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
 			if (fds.revents & POLLOUT) {
 				continue;
 			}
-			if (fds.revents & POLLERR) {
-				return oops(compress, EIO, "poll returned error!");
-			}
 		}
 		/* write avail bytes */
 		if (size > avail.avail)
@@ -438,6 +438,9 @@ int compress_read(struct compress *compress, void *buf, unsigned int size)
 				return total;
 
 			ret = poll(&fds, 1, compress->max_poll_wait_ms);
+			if (fds.revents & POLLERR) {
+				return oops(compress, EIO, "poll returned error!");
+			}
 			/* A pause will cause -EBADFD or zero.
 			 * This is not an error, just stop reading */
 			if ((ret == 0) || (ret == -EBADFD))
@@ -447,9 +450,6 @@ int compress_read(struct compress *compress, void *buf, unsigned int size)
 			if (fds.revents & POLLIN) {
 				continue;
 			}
-			if (fds.revents & POLLERR) {
-				return oops(compress, EIO, "poll returned error!");
-			}
 		}
 		/* read avail bytes */
 		if (size > avail.avail)
@@ -616,15 +616,15 @@ 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!");
+	}
 	/* A pause will cause -EBADFD or zero. */
 	if ((ret < 0) && (ret != -EBADFD))
 		return oops(compress, errno, "poll error");
 	if (fds.revents & (POLLOUT | POLLIN)) {
 		return 0;
 	}
-	if (fds.revents & POLLERR) {
-		return oops(compress, EIO, "poll returned error!");
-	}
 	return ret;
 }
 
-- 
1.7.2.5

             reply	other threads:[~2013-08-29  8:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-29  8:32 Richard Fitzgerald [this message]
2013-09-25 10:15 ` [TINYCOMPRESS][PATCH 1/1] compress: Must check for POLLERR before POLLOUT/POLLIN Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130829083202.GA1538@opensource.wolfsonmicro.com \
    --to=rf@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=elaurent@google.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.