Skip to content

Commit

Permalink
xenbus: avoid zero returns from read()
Browse files Browse the repository at this point in the history
It is possible to get a zero return from read() in instances where the
queue is not empty but has no elements with data to deliver to the user.
Since a zero return from read is an error indicator, resume waiting or
return -EAGAIN (for a nonblocking fd) in this case.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Daniel De Graaf authored and Jeremy Fitzhardinge committed Sep 9, 2010
1 parent 76ce761 commit 7808121
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/xen/xenfs/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static ssize_t xenbus_file_read(struct file *filp,
int ret;

mutex_lock(&u->reply_mutex);
again:
while (list_empty(&u->read_buffers)) {
mutex_unlock(&u->reply_mutex);
if (filp->f_flags & O_NONBLOCK)
Expand Down Expand Up @@ -158,6 +159,8 @@ static ssize_t xenbus_file_read(struct file *filp,
struct read_buffer, list);
}
}
if (i == 0)
goto again;

out:
mutex_unlock(&u->reply_mutex);
Expand Down

0 comments on commit 7808121

Please sign in to comment.