Commit 88117a25 authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

[PATCH] random: cleanup waitqueue logic, fix missed wakeup

Original code checked in output pool for missed wakeup avoidance, while waker
(batch_entropy_process) checked input pool which could result in a missed
wakeup.

- Move to wait_event_interruptible style

- Delete superfluous waitqueue
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fcff6bbf
......@@ -1587,7 +1587,6 @@ void rand_initialize_disk(struct gendisk *disk)
static ssize_t
random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
{
DECLARE_WAITQUEUE(wait, current);
ssize_t n, retval = 0, count = 0;
if (nbytes == 0)
......@@ -1613,20 +1612,20 @@ random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
retval = -EAGAIN;
break;
}
DEBUG_ENT("sleeping?\n");
wait_event_interruptible(random_read_wait,
random_state->entropy_count >=
random_read_wakeup_thresh);
DEBUG_ENT("awake\n");
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&random_read_wait, &wait);
if (sec_random_state->entropy_count / 8 == 0)
schedule();
set_current_state(TASK_RUNNING);
remove_wait_queue(&random_read_wait, &wait);
continue;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment