public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl,
	teemux.tuominen@intel.com
Subject: Re: [RFC v2 4/4] v4l: events: Don't sleep in dequeue if none are subscribed
Date: Wed, 02 Oct 2013 20:12:17 +0200	[thread overview]
Message-ID: <2284638.0TjbNMnX7g@avalon> (raw)
In-Reply-To: <1380721516-488-5-git-send-email-sakari.ailus@linux.intel.com>

Hi Sakari,

On Wednesday 02 October 2013 16:45:16 Sakari Ailus wrote:
> Dequeueing events was is entirely possible even if none are subscribed,

was or is ? :-)

> leading to sleeping indefinitely. Fix this by returning -ENOENT when no
> events are subscribed.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/v4l2-core/v4l2-event.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-event.c
> b/drivers/media/v4l2-core/v4l2-event.c index b53897e..553a800 100644
> --- a/drivers/media/v4l2-core/v4l2-event.c
> +++ b/drivers/media/v4l2-core/v4l2-event.c
> @@ -77,10 +77,17 @@ int v4l2_event_dequeue(struct v4l2_fh *fh, struct
> v4l2_event *event, mutex_unlock(fh->vdev->lock);
> 
>  	do {
> -		ret = wait_event_interruptible(fh->wait,
> -					       fh->navailable != 0);
> +		bool subscribed;
> +		ret = wait_event_interruptible(
> +			fh->wait,
> +			fh->navailable != 0 ||
> +			!(subscribed = v4l2_event_has_subscribed(fh)));
>  		if (ret < 0)
>  			break;
> +		if (!subscribed) {
> +			ret = -EIO;
> +			break;
> +		}
> 
>  		ret = __v4l2_event_dequeue(fh, event);
>  	} while (ret == -ENOENT);
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2013-10-02 18:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 13:45 [RFC v2 0/4] Sakari Ailus
2013-10-02 13:45 ` [RFC v2 1/4] v4l: return POLLERR on V4L2 sub-devices if no events are subscribed Sakari Ailus
2013-10-02 14:05   ` Hans Verkuil
2013-10-02 13:45 ` [RFC v2 2/4] v4l: vb2: Only poll for events if the user is interested in them Sakari Ailus
2013-10-02 14:07   ` Hans Verkuil
2013-10-02 13:45 ` [RFC v2 3/4] v4l: vb2: Return POLLERR when polling for events and none are subscribed Sakari Ailus
2013-10-02 13:59   ` Hans Verkuil
2013-10-02 14:21     ` Sakari Ailus
2013-10-02 13:45 ` [RFC v2 4/4] v4l: events: Don't sleep in dequeue if " Sakari Ailus
2013-10-02 14:04   ` Hans Verkuil
2013-10-02 14:18     ` Sakari Ailus
2013-10-02 14:37       ` Hans Verkuil
2013-10-02 14:45         ` Sakari Ailus
2013-10-03  9:29           ` Hans Verkuil
2013-10-02 14:49         ` Sakari Ailus
2013-10-03  9:49           ` Hans Verkuil
2013-10-02 18:12   ` Laurent Pinchart [this message]
2013-10-02 20:23     ` Sakari Ailus
2013-10-02 14:00 ` [RFC v2 0/4] Hans Verkuil
2013-10-02 18:15 ` Laurent Pinchart
2013-10-02 20:22   ` Sakari Ailus

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=2284638.0TjbNMnX7g@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=teemux.tuominen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox