diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-11 09:14:07 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-12-16 04:18:31 -0500 |
commit | 3ebb8ceb0fb62011c107396a6161595a064da95e (patch) | |
tree | e1fe83a457d0d64fd7c2f0493da702e99be73665 | |
parent | 70966777a4cf45a09e92b5c793dbfe906adf6071 (diff) |
ftdev: respect O_NONBLOCK flag in ftdev_read()
Don't block if userspace wants to go on doing something else.
-rw-r--r-- | litmus/ftdev.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/litmus/ftdev.c b/litmus/ftdev.c index 3722a523b157..6de7b169df93 100644 --- a/litmus/ftdev.c +++ b/litmus/ftdev.c | |||
@@ -216,6 +216,17 @@ static ssize_t ftdev_read(struct file *filp, | |||
216 | * here with copied data because that data would get | 216 | * here with copied data because that data would get |
217 | * lost if the task is interrupted (e.g., killed). | 217 | * lost if the task is interrupted (e.g., killed). |
218 | */ | 218 | */ |
219 | |||
220 | /* Before sleeping, check wether a non-blocking | ||
221 | * read was requested. | ||
222 | */ | ||
223 | if (filp->f_flags & O_NONBLOCK) | ||
224 | { | ||
225 | /* bug out, userspace doesn't want us to sleep */ | ||
226 | err = -EWOULDBLOCK; | ||
227 | break; | ||
228 | } | ||
229 | |||
219 | mutex_unlock(&ftdm->lock); | 230 | mutex_unlock(&ftdm->lock); |
220 | set_current_state(TASK_INTERRUPTIBLE); | 231 | set_current_state(TASK_INTERRUPTIBLE); |
221 | 232 | ||