From 74698a2a2030bde9ddac77ca92f4f398469b38cf Mon Sep 17 00:00:00 2001 From: Divakar Date: Tue, 6 Sep 2016 11:32:11 +0530 Subject: [PATCH] In HashTables, handle the error case if deferred work entry creation fails Right now, if the deferred work entry creation fails, we do not take any ation. This can result in, Hash bucket never being cleaned up, as there is no work entry scheduled at all. As a fix, reset the work entry 'scheduled' variable, so that, it gets scheduled when the next hash entry is attemped for deletion in that bucket Change-Id: Ia66bd340177253ac1267aa667521c26838487dbe partial-bug: #1618375 --- dp-core/vr_htable.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dp-core/vr_htable.c b/dp-core/vr_htable.c index 027d2cccd..1eddc05fe 100644 --- a/dp-core/vr_htable.c +++ b/dp-core/vr_htable.c @@ -385,8 +385,17 @@ vr_htable_release_hentry(vr_htable_t htable, vr_hentry_t *ent) /* Schedule the deletion on a cpu based on bucket index */ cpu_num = head_ent->hentry_index % vr_num_cpus; - vr_schedule_work(cpu_num, vr_htable_hentry_scheduled_delete, - (void *)delete_data); + if (vr_schedule_work(cpu_num, vr_htable_hentry_scheduled_delete, + (void *)delete_data)) { + /* + * We can only write back the status as not scheduled. There + * might be some entries that get marked as Deleted, but + * would not be pushed to free list as work queue is not + * scheduled. These marked entries would be deleted only if + * this hash bucket is revisisted + */ + (void)__sync_bool_compare_and_swap(&delete_data->hd_scheduled,1, 0); + } } return;