From: Michael Vrable Date: Mon, 27 Sep 2010 20:28:57 +0000 (-0700) Subject: Fix for journal committing. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=3e5285d5e2ffe02fcbc61d2ede540edca173595f;p=bluesky.git Fix for journal committing. Sometimes we could previously, under load, report that journal items were committed when they were not. Try to track the uncommitted state more carefully now. --- diff --git a/bluesky/bluesky-private.h b/bluesky/bluesky-private.h index 61238eb..dd55729 100644 --- a/bluesky/bluesky-private.h +++ b/bluesky/bluesky-private.h @@ -229,6 +229,7 @@ struct cloudlog_header { #define CLOUDLOG_JOURNAL 0x01 #define CLOUDLOG_CLOUD 0x02 #define CLOUDLOG_CACHE 0x04 +#define CLOUDLOG_UNCOMMITTED 0x10 struct _BlueSkyCloudLog { gint refcount; GMutex *lock; diff --git a/bluesky/log.c b/bluesky/log.c index b5c643f..87639db 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -67,7 +67,8 @@ static void log_commit(BlueSkyLog *log) g_mutex_lock(item->lock); bluesky_cloudlog_stats_update(item, -1); item->pending_write &= ~CLOUDLOG_JOURNAL; - item->location_flags |= CLOUDLOG_JOURNAL; + item->location_flags + = (item->location_flags & ~CLOUDLOG_UNCOMMITTED) | CLOUDLOG_JOURNAL; bluesky_cloudlog_stats_update(item, 1); g_cond_signal(item->cond); g_mutex_unlock(item->lock); @@ -279,9 +280,12 @@ BlueSkyLog *bluesky_log_new(const char *log_directory) void bluesky_log_item_submit(BlueSkyCloudLog *item, BlueSkyLog *log) { - bluesky_cloudlog_ref(item); - g_atomic_int_add(&item->data_lock_count, 1); - g_async_queue_push(log->queue, item); + if (!(item->location_flags & CLOUDLOG_JOURNAL)) { + bluesky_cloudlog_ref(item); + item->location_flags |= CLOUDLOG_UNCOMMITTED; + g_atomic_int_add(&item->data_lock_count, 1); + g_async_queue_push(log->queue, item); + } } void bluesky_log_finish_all(GList *log_items) @@ -290,7 +294,7 @@ void bluesky_log_finish_all(GList *log_items) BlueSkyCloudLog *item = (BlueSkyCloudLog *)log_items->data; g_mutex_lock(item->lock); - while ((item->pending_write & CLOUDLOG_JOURNAL)) + while ((item->location_flags & CLOUDLOG_UNCOMMITTED)) g_cond_wait(item->cond, item->lock); g_mutex_unlock(item->lock); bluesky_cloudlog_unref(item);