[PATCH] drm: Honour O_NONBLOCK on the device for reading events
Alan Cox
alan at lxorguk.ukuu.org.uk
Wed Jun 8 15:40:35 PDT 2011
On Wed, 8 Jun 2011 20:14:01 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:
> Otherwise drmHandleEvent will block if accidentally read too often...
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Phillip Haddad <phillip.haddad at gmail.com>
> ---
> drivers/gpu/drm/drm_fops.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 2ec7d48..279aa95 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -617,6 +617,9 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
> size_t total;
> ssize_t ret;
>
> + if (filp->f_flags & O_NONBLOCK && list_empty(&file_priv->event_list))
> + return -EAGAIN;
> +
> ret = wait_event_interruptible(file_priv->event_wait,
> !list_empty(&file_priv->event_list));
> if (ret < 0)
What happens if someone else empties the list between the test and the
wait_event_interruptible ?
More information about the dri-devel
mailing list