[sheepdog] [PATCH] object cache: fix crash when deleting object cache

levin li levin108 at gmail.com
Wed Sep 5 05:13:33 CEST 2012


From: levin li <xingke.lwp at taobao.com>


Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 sheep/object_cache.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 431fe26..5bd7060 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -602,6 +602,7 @@ not_found:
 
 		cache->dirty_tree = RB_ROOT;
 		INIT_LIST_HEAD(&cache->dirty_list);
+		INIT_LIST_HEAD(&cache->object_list);
 
 		pthread_rwlock_init(&cache->lock, NULL);
 		hlist_add_head(&cache->hash, head);
@@ -655,6 +656,7 @@ static void add_to_object_cache(struct object_cache *oc, uint32_t idx,
 	if (!old) {
 		dprintf("oid %"PRIx64"\n", idx_to_oid(oc->vid, idx));
 		uatomic_add(&sys_cache.cache_size, data_length);
+		list_add(&entry->object_list, &oc->object_list);
 		cds_list_add_rcu(&entry->lru_list, &sys_cache.cache_lru_list);
 	} else {
 		free(entry);
-- 
1.7.1




More information about the sheepdog mailing list