aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xenfs
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2010-09-08 18:10:42 -0400
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2010-09-08 20:48:22 -0400
commit7808121b9a1e44ef12fecd49fa6c268f27a150fc (patch)
tree5536cceff908e630d1a15c4f63abd7210ed4973b /drivers/xen/xenfs
parent76ce7618f9a24f7b13958c67f7d5ccfcdab71475 (diff)
xenbus: avoid zero returns from read()
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>
Diffstat (limited to 'drivers/xen/xenfs')
-rw-r--r--drivers/xen/xenfs/xenbus.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
index c4c7db8363e7..55791dd1105f 100644
--- a/drivers/xen/xenfs/xenbus.c
+++ b/drivers/xen/xenfs/xenbus.c
@@ -120,6 +120,7 @@ static ssize_t xenbus_file_read(struct file *filp,
120 int ret; 120 int ret;
121 121
122 mutex_lock(&u->reply_mutex); 122 mutex_lock(&u->reply_mutex);
123again:
123 while (list_empty(&u->read_buffers)) { 124 while (list_empty(&u->read_buffers)) {
124 mutex_unlock(&u->reply_mutex); 125 mutex_unlock(&u->reply_mutex);
125 if (filp->f_flags & O_NONBLOCK) 126 if (filp->f_flags & O_NONBLOCK)
@@ -158,6 +159,8 @@ static ssize_t xenbus_file_read(struct file *filp,
158 struct read_buffer, list); 159 struct read_buffer, list);
159 } 160 }
160 } 161 }
162 if (i == 0)
163 goto again;
161 164
162out: 165out:
163 mutex_unlock(&u->reply_mutex); 166 mutex_unlock(&u->reply_mutex);