Add runtime options to disable some of the log-structured optimizations
[bluesky.git] / bluesky / log.c
index 03f4fb3..6ac7508 100644 (file)
@@ -550,6 +550,8 @@ static void cloudlog_partial_fetch_complete(BlueSkyStoreAsync *async,
             g_warning("Unable to open and write to cache file %s: %m",
                       cachefile->filename);
         }
+
+        bluesky_rangeset_free(items);
     } else {
         g_print("Error fetching from cloud, retrying...\n");
         cloudlog_partial_fetch_start(cachefile, async->start, async->len);
@@ -649,7 +651,8 @@ BlueSkyRCStr *bluesky_log_map_object(BlueSkyCloudLog *item, gboolean map_data)
     BlueSkyRCStr *str = NULL;
     int location = 0;
     size_t file_offset = 0, file_size = 0;
-    gboolean range_request = TRUE;
+    gboolean range_request = bluesky_options.full_segment_fetches
+                              ? FALSE : TRUE;
 
     if (page_size == 0) {
         page_size = getpagesize();
@@ -749,7 +752,7 @@ void bluesky_mmap_unref(BlueSkyCacheFile *mmap)
 
     if (g_atomic_int_dec_and_test(&mmap->mapcount)) {
         g_mutex_lock(mmap->lock);
-        if (mmap->addr != NULL) {
+        if (mmap->addr != NULL && g_atomic_int_get(&mmap->mapcount) == 0) {
             if (bluesky_verbose)
                 g_print("Unmapped log segment %d...\n", mmap->log_seq);
             munmap((void *)mmap->addr, mmap->len);