More work on writeback caching.
[bluesky.git] / bluesky / store.c
index cc8a5e4..022deeb 100644 (file)
@@ -110,7 +110,8 @@ void bluesky_store_async_unref(BlueSkyStoreAsync *async)
         g_free(async->key);
         bluesky_string_unref(async->data);
         g_free(async);
-        g_print("Freed async\n");
+        g_log("bluesky/store", G_LOG_LEVEL_DEBUG,
+              "freeing async");
     }
 }
 
@@ -173,29 +174,29 @@ void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async)
     }
 }
 
-static void test_notifier(gpointer a, gpointer u)
-{
-    g_print("Notifier called!\n");
-}
-
 void bluesky_store_async_submit(BlueSkyStoreAsync *async)
 {
     BlueSkyStore *store = async->store;
 
     /* Barriers are handled specially, and not handed down the storage
      * implementation layer. */
-    if (async->op = STORE_OP_BARRIER) {
+    if (async->op == STORE_OP_BARRIER) {
         async->status = ASYNC_RUNNING;
         if (GPOINTER_TO_INT(async->store_private) == 0)
             bluesky_store_async_mark_complete(async);
         return;
     }
 
+    g_log("bluesky/store", G_LOG_LEVEL_DEBUG, "submit: %s %s",
+          async->op == STORE_OP_GET ? "GET"
+            : async->op == STORE_OP_PUT ? "PUT"
+            : async->op == STORE_OP_DELETE ? "DELETE" : "???",
+          async->key);
+
     g_mutex_lock(async->store->lock);
     async->store->pending++;
     g_mutex_unlock(async->store->lock);
 
-    bluesky_store_async_add_notifier(async, test_notifier, NULL);
     store->impl->submit(store->handle, async);
 
     if (bluesky_options.synchronous_stores)
@@ -204,7 +205,6 @@ void bluesky_store_async_submit(BlueSkyStoreAsync *async)
 
 static void op_complete(gpointer a, gpointer b)
 {
-    BlueSkyStoreAsync *async = (BlueSkyStoreAsync *)a;
     BlueSkyStoreAsync *barrier = (BlueSkyStoreAsync *)b;
 
     g_mutex_lock(barrier->lock);
@@ -225,7 +225,7 @@ void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier,
     g_return_if_fail(barrier->op == STORE_OP_BARRIER);
     barrier->store_private
         = GINT_TO_POINTER(GPOINTER_TO_INT(barrier->store_private) + 1);
-    bluesky_store_async_add_notifier(async, op_complete, NULL);
+    bluesky_store_async_add_notifier(async, op_complete, barrier);
 }
 
 static void notifier_task(gpointer n, gpointer s)