Values in the kvstore are raw byte arrays, not strings.
[bluesky.git] / bluesky / s3store.c
index 5ab42e1..ccf0878 100644 (file)
@@ -59,7 +59,6 @@ static int s3store_put_handler(int bufferSize, char *buffer,
 static S3Status s3store_properties_callback(const S3ResponseProperties *properties,
                                      void *callbackData)
 {
-    g_print("(Properties callback)\n");
     return S3StatusOK;
 }
 
@@ -69,14 +68,11 @@ static void s3store_response_callback(S3Status status,
 {
     struct get_info *info = (struct get_info *)callbackData;
 
-    g_print("S3 operation complete, status=%s, now=%ld\n",
-            S3_get_status_name(status), bluesky_now_hires());
-
     if (status == 0) {
         info->success = 1;
     }
 
-    if (errorDetails != NULL) {
+    if (errorDetails != NULL && errorDetails->message != NULL) {
         g_print("  Error message: %s\n", errorDetails->message);
     }
 }
@@ -86,7 +82,6 @@ static void s3store_task(gpointer a, gpointer s)
     BlueSkyStoreAsync *async = (BlueSkyStoreAsync *)a;
     S3Store *store = (S3Store *)s;
 
-    g_print("Start task [key=%s]...\n", async->key);
     async->status = ASYNC_RUNNING;
 
     if (async->op == STORE_OP_GET) {
@@ -99,7 +94,6 @@ static void s3store_task(gpointer a, gpointer s)
         handler.responseHandler.completeCallback = s3store_response_callback;
         handler.getObjectDataCallback = s3store_get_handler;
 
-        g_print("Starting fetch of %s from S3...\n", async->key);
         S3_get_object(&store->bucket, async->key, NULL, 0, 0, NULL,
                       &handler, &info);
 
@@ -128,8 +122,6 @@ static void s3store_task(gpointer a, gpointer s)
         handler.responseHandler.completeCallback = s3store_response_callback;
         handler.putObjectDataCallback = s3store_put_handler;
 
-        g_print("Starting store of %s to S3 at %ld...\n",
-                async->key, bluesky_now_hires());
         S3_put_object(&store->bucket, async->key, encrypted->len, NULL, NULL,
                       &handler, &info);
 
@@ -138,10 +130,8 @@ static void s3store_task(gpointer a, gpointer s)
         async->result = 0;
     }
 
-    // TODO: Deallocate resources
-
-    g_print("Finish task...\n");
     bluesky_store_async_mark_complete(async);
+    bluesky_store_async_unref(async);
 }
 
 static gpointer s3store_new()
@@ -184,6 +174,7 @@ static void s3store_submit(gpointer s, BlueSkyStoreAsync *async)
     case STORE_OP_GET:
     case STORE_OP_PUT:
         async->status = ASYNC_PENDING;
+        bluesky_store_async_ref(async);
         g_thread_pool_push(store->thread_pool, async, NULL);
         break;