Fix a memory leak resulting from the in-memory inode map.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 21 Oct 2010 05:34:45 +0000 (22:34 -0700)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 21 Oct 2010 05:34:45 +0000 (22:34 -0700)
Actually release the reference to the old version of an inode when creating
a new one.

bluesky/cloudlog.c
bluesky/imap.c

index b2f95c7..116195c 100644 (file)
@@ -392,6 +392,7 @@ BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log,
         g_mutex_lock(fs->lock);
         InodeMapEntry *entry = bluesky_inode_map_lookup(fs->inode_map,
                                                         log->inum, 1);
+        bluesky_cloudlog_unref_delayed(entry->item);
         entry->item = log;
         bluesky_cloudlog_ref(entry->item);
         g_mutex_unlock(fs->lock);
index ec27d43..9b5f8e3 100644 (file)
@@ -250,6 +250,7 @@ static void bluesky_inode_map_deserialize(BlueSkyFS *fs, BlueSkyCloudLog *imap)
             InodeMapEntry *entry;
             entry = bluesky_inode_map_lookup(fs->inode_map, *inum, 1);
             entry->inum = GUINT64_FROM_LE(*inum);
+            bluesky_cloudlog_unref_delayed(entry->item);
             entry->item = g_array_index(section->links,
                                         BlueSkyCloudLog *, j);
             bluesky_cloudlog_ref(entry->item);