aboutsummaryrefslogtreecommitdiff
path: root/backends/rng-random.c
diff options
context:
space:
mode:
authorLadi Prosek <lprosek@redhat.com>2016-03-03 14:16:11 +0100
committerAmit Shah <amit.shah@redhat.com>2016-03-08 12:54:14 +0530
commit443590c2044968a97f5e7cddd35100c6075856a4 (patch)
tree55fffa1528d3d3e52f9d2f64afb750d380927910 /backends/rng-random.c
parent97556fe80e4f7252300b3498b3477fb4295153a3 (diff)
rng: switch request queue to QSIMPLEQ
QSIMPLEQ supports appending to tail in O(1) and is intrusive so it doesn't require extra memory allocations for the bookkeeping data. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Message-Id: <1457010971-24771-1-git-send-email-lprosek@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'backends/rng-random.c')
-rw-r--r--backends/rng-random.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/backends/rng-random.c b/backends/rng-random.c
index a6cb3858e3..122e8d494d 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -35,8 +35,8 @@ static void entropy_available(void *opaque)
{
RndRandom *s = RNG_RANDOM(opaque);
- while (s->parent.requests != NULL) {
- RngRequest *req = s->parent.requests->data;
+ while (!QSIMPLEQ_EMPTY(&s->parent.requests)) {
+ RngRequest *req = QSIMPLEQ_FIRST(&s->parent.requests);
ssize_t len;
len = read(s->fd, req->data, req->size);
@@ -58,7 +58,7 @@ static void rng_random_request_entropy(RngBackend *b, RngRequest *req)
{
RndRandom *s = RNG_RANDOM(b);
- if (s->parent.requests == NULL) {
+ if (QSIMPLEQ_EMPTY(&s->parent.requests)) {
/* If there are no pending requests yet, we need to
* install our fd handler. */
qemu_set_fd_handler(s->fd, entropy_available, NULL, s);