[Sheepdog] fix fd leak RE: [PATCH v2 3/7] sheep: object cache proper

huxinwei huxinwei at huawei.com
Tue Mar 13 10:08:06 CET 2012


Preventing cache_object_fd leak while being called in object_is_cached.

On the other hand, I do this think this part of code is subject to refactoring.
The usage of cache_object_fd is really subtle ;)

FYI.

Signed-off-by: Xinwei Hu <huxinwei at huawei.com >

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 27a64a9..f75b7a1 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -457,8 +457,10 @@ int object_is_cached(uint64_t oid)
        cache->oid = oid;
        if (object_cache_lookup(cache, idx) < 0)
                return 0;
-       else
+       else {
+               close(cache_object_fd);
                return 1; /* found it */
+       }
 }

 int object_cache_init(const char *p)





More information about the sheepdog mailing list