diff options
author | Ladi Prosek <lprosek@redhat.com> | 2016-03-03 09:37:17 +0100 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2016-03-03 17:42:26 +0530 |
commit | 9f14b0add1dcdbfa2ee61051d068211fb0a1fcc9 (patch) | |
tree | dc14b6dbc59318bed325db89f613160a7307bd5c /backends/rng-egd.c | |
parent | 74074e8a7c60592cf1cc6469dbc2550d24aeded3 (diff) |
rng: move request queue cleanup from RngEgd to RngBackend
RngBackend is now in charge of cleaning up the linked list on
instance finalization. It also exposes a function to finalize
individual RngRequest instances, called by its child classes.
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Message-Id: <1456994238-9585-4-git-send-email-lprosek@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'backends/rng-egd.c')
-rw-r--r-- | backends/rng-egd.c | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/backends/rng-egd.c b/backends/rng-egd.c index b061362e29..8f2bd16b18 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -58,12 +58,6 @@ static void rng_egd_request_entropy(RngBackend *b, size_t size, s->parent.requests = g_slist_append(s->parent.requests, req); } -static void rng_egd_free_request(RngRequest *req) -{ - g_free(req->data); - g_free(req); -} - static int rng_egd_chr_can_read(void *opaque) { RngEgd *s = RNG_EGD(opaque); @@ -93,28 +87,13 @@ static void rng_egd_chr_read(void *opaque, const uint8_t *buf, int size) size -= len; if (req->offset == req->size) { - s->parent.requests = g_slist_remove_link(s->parent.requests, - s->parent.requests); - req->receive_entropy(req->opaque, req->data, req->size); - rng_egd_free_request(req); + rng_backend_finalize_request(&s->parent, req); } } } -static void rng_egd_free_requests(RngEgd *s) -{ - GSList *i; - - for (i = s->parent.requests; i; i = i->next) { - rng_egd_free_request(i->data); - } - - g_slist_free(s->parent.requests); - s->parent.requests = NULL; -} - static void rng_egd_opened(RngBackend *b, Error **errp) { RngEgd *s = RNG_EGD(b); @@ -183,8 +162,6 @@ static void rng_egd_finalize(Object *obj) } g_free(s->chr_name); - - rng_egd_free_requests(s); } static void rng_egd_class_init(ObjectClass *klass, void *data) |