A few attempted bugfixes for log data lifetimes.
[bluesky.git] / bluesky / store.c
index 2043806..23e7047 100644 (file)
@@ -231,10 +231,12 @@ void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async)
               async, elapsed, latency);
     }
 
-    if (async->op == STORE_OP_GET) {
-        bluesky_stats_add(async->store->stats_get, 1);
-    } else if (async->op == STORE_OP_PUT) {
-        bluesky_stats_add(async->store->stats_put, 1);
+    if (async->data) {
+        if (async->op == STORE_OP_GET) {
+            bluesky_stats_add(async->store->stats_get, async->data->len);
+        } else if (async->op == STORE_OP_PUT) {
+            bluesky_stats_add(async->store->stats_put, async->data->len);
+        }
     }
 }
 
@@ -290,13 +292,15 @@ void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier,
     g_mutex_unlock(barrier->lock);
 
     g_mutex_lock(async->lock);
-    if (async->barrier == NULL) {
+    if (async->barrier == NULL && async->status != ASYNC_COMPLETE) {
         async->barrier = barrier;
+        g_mutex_unlock(async->lock);
     } else {
-        g_warning("Adding async to more than one barrier!\n");
+        if (async->barrier != NULL)
+            g_warning("Adding async to more than one barrier!\n");
+        g_mutex_unlock(async->lock);
         bluesky_store_async_add_notifier(async, op_complete, barrier);
     }
-    g_mutex_unlock(async->lock);
 }
 
 static void notifier_task(gpointer n, gpointer s)