gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36929 - gnunet/src/datastore


From: gnunet
Subject: [GNUnet-SVN] r36929 - gnunet/src/datastore
Date: Mon, 14 Mar 2016 23:40:04 +0100

Author: grothoff
Date: 2016-03-14 23:40:04 +0100 (Mon, 14 Mar 2016)
New Revision: 36929

Modified:
   gnunet/src/datastore/gnunet-service-datastore.c
   gnunet/src/datastore/plugin_datastore_postgres.c
   gnunet/src/datastore/test_datastore_api.c
Log:
-bugfix, adding comments, fixing indent

Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c     2016-03-09 16:57:52 UTC 
(rev 36928)
+++ gnunet/src/datastore/gnunet-service-datastore.c     2016-03-14 22:40:04 UTC 
(rev 36929)
@@ -681,7 +681,8 @@
   uint64_t amount;
   uint32_t entries;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERVE");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Processing RESERVE request\n");
   amount = GNUNET_ntohll (msg->amount);
   entries = ntohl (msg->entries);
   used = payload + reserved;
@@ -757,8 +758,7 @@
   unsigned long long rem;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' request\n",
-              "RELEASE_RESERVE");
+              "Processing RELEASE_RESERVE request\n");
   next = reservations;
   prev = NULL;
   while (NULL != (pos = next))
@@ -905,6 +905,12 @@
 }
 
 
+/**
+ *
+ * @param cls closure
+ * @param status #GNUNET_OK or #GNUNET_SYSERR
+ * @param msg error message on error
+ */
 static void
 check_present_continuation (void *cls,
                            int status,
@@ -954,10 +960,10 @@
     execute_put (pc);
     return GNUNET_OK;
   }
-  if ((GNUNET_BLOCK_TYPE_FS_DBLOCK == type) ||
-      (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || ((size == ntohl (dm->size)) &&
-                                                (0 ==
-                                                 memcmp (&dm[1], data, size))))
+  if ( (GNUNET_BLOCK_TYPE_FS_DBLOCK == type) ||
+       (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) ||
+       ( (size == ntohl (dm->size)) &&
+         (0 == memcmp (&dm[1], data, size)) ) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Result already present in datastore\n");
@@ -994,7 +1000,8 @@
  * @param message the actual message
  */
 static void
-handle_put (void *cls, struct GNUNET_SERVER_Client *client,
+handle_put (void *cls,
+            struct GNUNET_SERVER_Client *client,
             const struct GNUNET_MessageHeader *message)
 {
   const struct DataMessage *dm = check_data (message);
@@ -1011,8 +1018,9 @@
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' request for `%s' of type %u\n", "PUT",
-              GNUNET_h2s (&dm->key), ntohl (dm->type));
+              "Processing PUT request for `%s' of type %u\n",
+              GNUNET_h2s (&dm->key),
+              ntohl (dm->type));
   rid = ntohl (dm->rid);
   size = ntohl (dm->size);
   if (rid > 0)
@@ -1063,7 +1071,8 @@
  * @param message the actual message
  */
 static void
-handle_get (void *cls, struct GNUNET_SERVER_Client *client,
+handle_get (void *cls,
+            struct GNUNET_SERVER_Client *client,
             const struct GNUNET_MessageHeader *message)
 {
   const struct GetMessage *msg;
@@ -1079,20 +1088,21 @@
   }
   msg = (const struct GetMessage *) message;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' request for `%s' of type %u\n", "GET",
-              GNUNET_h2s (&msg->key), ntohl (msg->type));
+              "Processing GET request for `%s' of type %u\n",
+              GNUNET_h2s (&msg->key),
+              ntohl (msg->type));
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# GET requests received"),
                             1,
                             GNUNET_NO);
   GNUNET_SERVER_client_keep (client);
-  if ((size == sizeof (struct GetMessage)) &&
-      (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)))
+  if ( (size == sizeof (struct GetMessage)) &&
+       (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)) )
   {
     /* don't bother database... */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Empty result set for `%s' request for `%s' (bloomfilter).\n",
-                "GET", GNUNET_h2s (&msg->key));
+                "Empty result set for GET request for `%s' (bloomfilter).\n",
+                GNUNET_h2s (&msg->key));
     GNUNET_STATISTICS_update (stats,
                               gettext_noop
                               ("# requests filtered by bloomfilter"),
@@ -1109,6 +1119,13 @@
 }
 
 
+/**
+ * Function called with the result of an update operation.
+ *
+ * @param cls closure
+ * @param status #GNUNET_OK or #GNUNET_SYSERR
+ * @param msg error message on error
+ */
 static void
 update_continuation (void *cls,
                     int status,
@@ -1129,7 +1146,8 @@
  * @param message the actual message
  */
 static void
-handle_update (void *cls, struct GNUNET_SERVER_Client *client,
+handle_update (void *cls,
+               struct GNUNET_SERVER_Client *client,
                const struct GNUNET_MessageHeader *message)
 {
   const struct UpdateMessage *msg;
@@ -1139,13 +1157,15 @@
                             1,
                             GNUNET_NO);
   msg = (const struct UpdateMessage *) message;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n",
-              "UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Processing UPDATE request for %llu\n",
+              (unsigned long long) GNUNET_ntohll (msg->uid));
   GNUNET_SERVER_client_keep (client);
-  plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid),
+  plugin->api->update (plugin->api->cls,
+                       GNUNET_ntohll (msg->uid),
                        (int32_t) ntohl (msg->priority),
                        GNUNET_TIME_absolute_ntoh (msg->expiration),
-                       update_continuation, client);
+                       &update_continuation, client);
 }
 
 
@@ -1157,7 +1177,8 @@
  * @param message the actual message
  */
 static void
-handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client,
+handle_get_replication (void *cls,
+                        struct GNUNET_SERVER_Client *client,
                         const struct GNUNET_MessageHeader *message)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1168,7 +1189,8 @@
                             1,
                             GNUNET_NO);
   GNUNET_SERVER_client_keep (client);
-  plugin->api->get_replication (plugin->api->cls, &transmit_item, client);
+  plugin->api->get_replication (plugin->api->cls,
+                                &transmit_item, client);
 }
 
 
@@ -1180,7 +1202,8 @@
  * @param message the actual message
  */
 static void
-handle_get_zero_anonymity (void *cls, struct GNUNET_SERVER_Client *client,
+handle_get_zero_anonymity (void *cls,
+                           struct GNUNET_SERVER_Client *client,
                            const struct GNUNET_MessageHeader *message)
 {
   const struct GetZeroAnonymityMessage *msg =
@@ -1203,7 +1226,8 @@
                             GNUNET_NO);
   GNUNET_SERVER_client_keep (client);
   plugin->api->get_zero_anonymity (plugin->api->cls,
-                                   GNUNET_ntohll (msg->offset), type,
+                                   GNUNET_ntohll (msg->offset),
+                                   type,
                                    &transmit_item, client);
 }
 
@@ -1210,21 +1234,37 @@
 
 /**
  * Callback function that will cause the item that is passed
- * in to be deleted (by returning GNUNET_NO).
+ * in to be deleted (by returning #GNUNET_NO).
+ *
+ * @param cls closure
+ * @param key key for the content
+ * @param size number of bytes in data
+ * @param data content stored
+ * @param type type of the content
+ * @param priority priority of the content
+ * @param anonymity anonymity-level for the content
+ * @param expiration expiration time for the content
+ * @param uid unique identifier for the datum
+ * @return #GNUNET_OK to keep the item
+ *         #GNUNET_NO to delete the item
  */
 static int
-remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
-                 const void *data, enum GNUNET_BLOCK_Type type,
-                 uint32_t priority, uint32_t anonymity,
-                 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
+remove_callback (void *cls,
+                 const struct GNUNET_HashCode *key,
+                 uint32_t size,
+                 const void *data,
+                 enum GNUNET_BLOCK_Type type,
+                 uint32_t priority,
+                 uint32_t anonymity,
+                 struct GNUNET_TIME_Absolute expiration,
+                 uint64_t uid)
 {
   struct GNUNET_SERVER_Client *client = cls;
 
-  if (key == NULL)
+  if (NULL == key)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "No further matches for `%s' request.\n",
-                "REMOVE");
+                "No further matches for REMOVE request.\n");
     transmit_status (client,
                      GNUNET_NO,
                      _("Content not found"));
@@ -1232,9 +1272,8 @@
     return GNUNET_OK;           /* last item */
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Item %llu matches `%s' request for key `%s' and type %u.\n",
+              "Item %llu matches REMOVE request for key `%s' and type %u.\n",
               (unsigned long long) uid,
-              "REMOVE",
               GNUNET_h2s (key),
               type);
   GNUNET_STATISTICS_update (stats,
@@ -1256,26 +1295,34 @@
  * @param message the actual message
  */
 static void
-handle_remove (void *cls, struct GNUNET_SERVER_Client *client,
+handle_remove (void *cls,
+               struct GNUNET_SERVER_Client *client,
                const struct GNUNET_MessageHeader *message)
 {
   const struct DataMessage *dm = check_data (message);
   struct GNUNET_HashCode vhash;
 
-  if (dm == NULL)
+  if (NULL == dm)
   {
     GNUNET_break (0);
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' request for `%s' of type %u\n", "REMOVE",
-              GNUNET_h2s (&dm->key), ntohl (dm->type));
-  GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests received"),
+  GNUNET_STATISTICS_update (stats,
+                            gettext_noop ("# REMOVE requests received"),
                             1, GNUNET_NO);
   GNUNET_SERVER_client_keep (client);
-  GNUNET_CRYPTO_hash (&dm[1], ntohl (dm->size), &vhash);
-  plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash,
+  GNUNET_CRYPTO_hash (&dm[1],
+                      ntohl (dm->size),
+                      &vhash);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Processing REMOVE request for `%s' of type %u\n",
+              GNUNET_h2s (&dm->key),
+              ntohl (dm->type));
+  plugin->api->get_key (plugin->api->cls,
+                        0,
+                        &dm->key,
+                        &vhash,
                         (enum GNUNET_BLOCK_Type) ntohl (dm->type),
                         &remove_callback, client);
 }
@@ -1289,12 +1336,12 @@
  * @param message the actual message
  */
 static void
-handle_drop (void *cls, struct GNUNET_SERVER_Client *client,
+handle_drop (void *cls,
+             struct GNUNET_SERVER_Client *client,
              const struct GNUNET_MessageHeader *message)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' request\n",
-              "DROP");
+              "Processing DROP request\n");
   do_drop = GNUNET_YES;
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }

Modified: gnunet/src/datastore/plugin_datastore_postgres.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_postgres.c    2016-03-09 16:57:52 UTC 
(rev 36928)
+++ gnunet/src/datastore/plugin_datastore_postgres.c    2016-03-14 22:40:04 UTC 
(rev 36929)
@@ -78,7 +78,7 @@
 
   ret =
       PQexec (plugin->dbh,
-              "CREATE TABLE gn090 (" 
+              "CREATE TABLE gn090 ("
              "  repl INTEGER NOT NULL DEFAULT 0,"
               "  type INTEGER NOT NULL DEFAULT 0,"
               "  prio INTEGER NOT NULL DEFAULT 0,"
@@ -87,7 +87,7 @@
               "  rvalue BIGINT NOT NULL DEFAULT 0,"
               "  hash BYTEA NOT NULL DEFAULT '',"
               "  vhash BYTEA NOT NULL DEFAULT '',"
-              "  value BYTEA NOT NULL DEFAULT '')" 
+              "  value BYTEA NOT NULL DEFAULT '')"
              "WITH OIDS");
   if ( (NULL == ret) ||
        ((PQresultStatus (ret) != PGRES_COMMAND_OK) &&
@@ -257,10 +257,10 @@
                     "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0,
                     NULL, NULL, NULL, NULL, 1);
   if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh, 
-                                   ret, 
-                                   PGRES_TUPLES_OK, 
-                                   "PQexecParams", 
+      GNUNET_POSTGRES_check_result (plugin->dbh,
+                                   ret,
+                                   PGRES_TUPLES_OK,
+                                   "PQexecParams",
                                    "get_size"))
   {
     *estimate = 0;
@@ -302,15 +302,15 @@
  * @param cont_cls continuation closure
  */
 static void
-postgres_plugin_put (void *cls, 
+postgres_plugin_put (void *cls,
                     const struct GNUNET_HashCode *key,
                     uint32_t size,
-                     const void *data, 
+                     const void *data,
                     enum GNUNET_BLOCK_Type type,
-                     uint32_t priority, 
+                     uint32_t priority,
                     uint32_t anonymity,
                      uint32_t replication,
-                     struct GNUNET_TIME_Absolute expiration, 
+                     struct GNUNET_TIME_Absolute expiration,
                     PluginPutCont cont,
                      void *cont_cls)
 {
@@ -335,22 +335,22 @@
                                 "put",
                                 params);
   if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh, 
-                                   ret, 
-                                   PGRES_COMMAND_OK, 
+      GNUNET_POSTGRES_check_result (plugin->dbh,
+                                   ret,
+                                   PGRES_COMMAND_OK,
                                    "PQexecPrepared", "put"))
   {
-    cont (cont_cls, key, size, 
-         GNUNET_SYSERR, 
+    cont (cont_cls, key, size,
+         GNUNET_SYSERR,
          _("Postgress exec failure"));
     return;
   }
   PQclear (ret);
-  plugin->env->duc (plugin->env->cls, 
+  plugin->env->duc (plugin->env->cls,
                    size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                   "datastore-postgres",
-                   "Stored %u bytes in database\n", 
+                   "Stored %u bytes in database\n",
                   (unsigned int) size);
   cont (cont_cls, key, size, GNUNET_OK, NULL);
 }
@@ -367,7 +367,7 @@
  * @param line line number for error messages
  */
 static void
-process_result (struct Plugin *plugin, 
+process_result (struct Plugin *plugin,
                PluginDatumProcessor proc,
                 void *proc_cls,
                PGresult * res,
@@ -394,9 +394,9 @@
   };
 
   if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result_ (plugin->dbh, 
-                                    res, 
-                                    PGRES_TUPLES_OK, 
+      GNUNET_POSTGRES_check_result_ (plugin->dbh,
+                                    res,
+                                    PGRES_TUPLES_OK,
                                     "PQexecPrepared",
                                     "select",
                                     filename, line))
@@ -404,7 +404,7 @@
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                     "datastore-postgres",
                      "Ending iteration (postgres error)\n");
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
@@ -412,15 +412,15 @@
   if (0 == PQntuples (res))
   {
     /* no result */
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                     "datastore-postgres",
                      "Ending iteration (no more results)\n");
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     PQclear (res);
     return;
   }
-  if (1 != PQntuples (res)) 
+  if (1 != PQntuples (res))
   {
     GNUNET_break (0);
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
@@ -436,23 +436,23 @@
     GNUNET_break (0);
     PQclear (res);
     GNUNET_POSTGRES_delete_by_rowid (plugin->dbh,
-                                    "delrow", 
+                                    "delrow",
                                     rowid);
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
 
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                   "datastore-postgres",
                    "Found result of size %u bytes and type %u in database\n",
-                   (unsigned int) size, 
+                   (unsigned int) size,
                   (unsigned int) utype);
   iret = proc (proc_cls,
               &key,
               size,
               data,
-              (enum GNUNET_BLOCK_Type) utype, 
+              (enum GNUNET_BLOCK_Type) utype,
               priority,
               anonymity,
               expiration_time,
@@ -461,20 +461,20 @@
   if (iret == GNUNET_NO)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Processor asked for item %u to be removed.\n", 
+                "Processor asked for item %u to be removed.\n",
                (unsigned int) rowid);
-    if (GNUNET_OK == 
-       GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, 
-                                        "delrow", 
+    if (GNUNET_OK ==
+       GNUNET_POSTGRES_delete_by_rowid (plugin->dbh,
+                                        "delrow",
                                         rowid))
     {
-      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                       "datastore-postgres",
                        "Deleting %u bytes from database\n",
                        (unsigned int) size);
       plugin->env->duc (plugin->env->cls,
                         - (size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
-      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                       "datastore-postgres",
                        "Deleted %u bytes from database\n",
                       (unsigned int) size);
@@ -503,7 +503,7 @@
  * @param proc_cls closure for iter
  */
 static void
-postgres_plugin_get_key (void *cls, 
+postgres_plugin_get_key (void *cls,
                         uint64_t offset,
                          const struct GNUNET_HashCode *key,
                          const struct GNUNET_HashCode *vhash,
@@ -521,7 +521,7 @@
   {
     if (NULL != vhash)
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_auto_from_type (vhash),
        GNUNET_PQ_query_param_uint32 (&utype),
@@ -533,7 +533,7 @@
     }
     else
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_uint32 (&utype),
        GNUNET_PQ_query_param_end
@@ -547,7 +547,7 @@
   {
     if (NULL != vhash)
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_auto_from_type (vhash),
        GNUNET_PQ_query_param_end
@@ -558,7 +558,7 @@
     }
     else
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_end
       };
@@ -569,23 +569,23 @@
   }
 
   if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh, 
+      GNUNET_POSTGRES_check_result (plugin->dbh,
                                    ret,
-                                   PGRES_TUPLES_OK, 
-                                   "PQexecParams", 
+                                   PGRES_TUPLES_OK,
+                                   "PQexecParams",
                                    "count"))
   {
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
-  if ( (PQntuples (ret) != 1) || 
+  if ( (PQntuples (ret) != 1) ||
        (PQnfields (ret) != 1) ||
        (PQgetlength (ret, 0, 0) != sizeof (uint64_t)))
   {
     GNUNET_break (0);
     PQclear (ret);
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
@@ -593,7 +593,7 @@
   PQclear (ret);
   if (0 == total)
   {
-    proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 
+    proc (proc_cls, NULL, 0, NULL, 0, 0, 0,
          GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
@@ -603,9 +603,9 @@
   {
     if (NULL != vhash)
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
-       GNUNET_PQ_query_param_auto_from_type (&vhash),
+       GNUNET_PQ_query_param_auto_from_type (vhash),
        GNUNET_PQ_query_param_uint32 (&utype),
        GNUNET_PQ_query_param_uint64 (&limit_off),
        GNUNET_PQ_query_param_end
@@ -616,7 +616,7 @@
     }
     else
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_uint32 (&utype),
        GNUNET_PQ_query_param_uint64 (&limit_off),
@@ -631,9 +631,9 @@
   {
     if (NULL != vhash)
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
-       GNUNET_PQ_query_param_auto_from_type (&vhash),
+       GNUNET_PQ_query_param_auto_from_type (vhash),
        GNUNET_PQ_query_param_uint64 (&limit_off),
        GNUNET_PQ_query_param_end
       };
@@ -643,7 +643,7 @@
     }
     else
     {
-      struct GNUNET_PQ_QueryParam params[] = { 
+      struct GNUNET_PQ_QueryParam params[] = {
        GNUNET_PQ_query_param_auto_from_type (key),
        GNUNET_PQ_query_param_uint64 (&limit_off),
        GNUNET_PQ_query_param_end
@@ -655,8 +655,8 @@
   }
   process_result (plugin,
                  proc,
-                 proc_cls, 
-                 ret, 
+                 proc_cls,
+                 ret,
                  __FILE__, __LINE__);
 }
 
@@ -675,15 +675,15 @@
  * @param proc_cls closure for @a proc
  */
 static void
-postgres_plugin_get_zero_anonymity (void *cls, 
+postgres_plugin_get_zero_anonymity (void *cls,
                                    uint64_t offset,
                                     enum GNUNET_BLOCK_Type type,
-                                    PluginDatumProcessor proc, 
+                                    PluginDatumProcessor proc,
                                    void *proc_cls)
 {
   struct Plugin *plugin = cls;
   uint32_t utype = type;
-  struct GNUNET_PQ_QueryParam params[] = { 
+  struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_uint32 (&utype),
     GNUNET_PQ_query_param_uint64 (&offset),
     GNUNET_PQ_query_param_end
@@ -694,7 +694,7 @@
                                 "select_non_anonymous",
                                 params);
 
-  process_result (plugin, 
+  process_result (plugin,
                  proc, proc_cls,
                  ret,
                  __FILE__, __LINE__);
@@ -739,7 +739,7 @@
  * @param expiration expiration time for the content
  * @param uid unique identifier for the datum;
  *        maybe 0 if no unique identifier is available
- * @return #GNUNET_SYSERR to abort the iteration, 
+ * @return #GNUNET_SYSERR to abort the iteration,
  *         #GNUNET_OK to continue
  *         (continue on call to "next", of course),
  *         #GNUNET_NO to delete the item and continue (if supported)
@@ -749,9 +749,9 @@
           const struct GNUNET_HashCode *key,
           uint32_t size,
            const void *data,
-          enum GNUNET_BLOCK_Type type, 
+          enum GNUNET_BLOCK_Type type,
           uint32_t priority,
-           uint32_t anonymity, 
+           uint32_t anonymity,
           struct GNUNET_TIME_Absolute expiration,
            uint64_t uid)
 {
@@ -759,17 +759,17 @@
   struct Plugin *plugin = rc->plugin;
   int ret;
   uint32_t oid = (uint32_t) uid;
-  struct GNUNET_PQ_QueryParam params[] = { 
+  struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_uint32 (&oid),
     GNUNET_PQ_query_param_end
   };
   PGresult *qret;
 
-  ret = rc->proc (rc->proc_cls, 
-                 key, 
-                 size, data, 
+  ret = rc->proc (rc->proc_cls,
+                 key,
+                 size, data,
                  type,
-                 priority, 
+                 priority,
                  anonymity,
                  expiration, uid);
   if (NULL == key)
@@ -778,9 +778,9 @@
                                  "decrepl",
                                  params);
   if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh, 
-                                   qret, 
-                                   PGRES_COMMAND_OK, 
+      GNUNET_POSTGRES_check_result (plugin->dbh,
+                                   qret,
+                                   PGRES_COMMAND_OK,
                                    "PQexecPrepared",
                                    "decrepl"))
     return GNUNET_SYSERR;
@@ -801,7 +801,7 @@
  * @param proc_cls closure for @a proc
  */
 static void
-postgres_plugin_get_replication (void *cls, 
+postgres_plugin_get_replication (void *cls,
                                 PluginDatumProcessor proc,
                                  void *proc_cls)
 {
@@ -812,13 +812,13 @@
   rc.plugin = plugin;
   rc.proc = proc;
   rc.proc_cls = proc_cls;
-  ret = PQexecPrepared (plugin->dbh, 
+  ret = PQexecPrepared (plugin->dbh,
                        "select_replication_order", 0, NULL, NULL,
                        NULL, 1);
-  process_result (plugin, 
-                 &repl_proc, 
-                 &rc, 
-                 ret, 
+  process_result (plugin,
+                 &repl_proc,
+                 &rc,
+                 ret,
                  __FILE__, __LINE__);
 }
 
@@ -832,13 +832,13 @@
  * @param proc_cls closure for @a proc
  */
 static void
-postgres_plugin_get_expiration (void *cls, 
+postgres_plugin_get_expiration (void *cls,
                                PluginDatumProcessor proc,
                                 void *proc_cls)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_TIME_Absolute now;
-  struct GNUNET_PQ_QueryParam params[] = { 
+  struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_absolute_time (&now),
     GNUNET_PQ_query_param_end
   };
@@ -879,8 +879,8 @@
  * @param cons_cls continuation closure
  */
 static void
-postgres_plugin_update (void *cls, 
-                       uint64_t uid, 
+postgres_plugin_update (void *cls,
+                       uint64_t uid,
                        int delta,
                         struct GNUNET_TIME_Absolute expire,
                         PluginUpdateCont cont,
@@ -889,7 +889,7 @@
   struct Plugin *plugin = cls;
   uint32_t idelta = delta;
   uint32_t oid = (uint32_t) uid;
-  struct GNUNET_PQ_QueryParam params[] = { 
+  struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_uint32 (&idelta),
     GNUNET_PQ_query_param_absolute_time (&expire),
     GNUNET_PQ_query_param_uint32 (&oid),
@@ -902,24 +902,23 @@
                                 params);
   if (GNUNET_OK !=
       GNUNET_POSTGRES_check_result (plugin->dbh,
-                                   ret, 
-                                   PGRES_COMMAND_OK, 
-                                   "PQexecPrepared", 
+                                   ret,
+                                   PGRES_COMMAND_OK,
+                                   "PQexecPrepared",
                                    "update"))
   {
-    cont (cont_cls, 
-         GNUNET_SYSERR, 
+    cont (cont_cls,
+         GNUNET_SYSERR,
          NULL);
     return;
   }
   PQclear (ret);
-  cont (cont_cls, 
-       GNUNET_OK, 
+  cont (cont_cls,
+       GNUNET_OK,
        NULL);
 }
 
 
-
 /**
  * Get all of the keys in the datastore.
  *
@@ -938,17 +937,17 @@
   struct GNUNET_HashCode key;
   PGresult * res;
 
-  res = PQexecPrepared (plugin->dbh, 
-                       "get_keys", 
+  res = PQexecPrepared (plugin->dbh,
+                       "get_keys",
                        0, NULL, NULL, NULL, 1);
   ret = PQntuples (res);
   for (i=0;i<ret;i++)
   {
-    if (sizeof (struct GNUNET_HashCode) != 
+    if (sizeof (struct GNUNET_HashCode) !=
        PQgetlength (res, i, 0))
     {
-      memcpy (&key, 
-             PQgetvalue (res, i, 0), 
+      memcpy (&key,
+             PQgetvalue (res, i, 0),
              sizeof (struct GNUNET_HashCode));
       proc (proc_cls, &key, 1);
     }
@@ -958,7 +957,6 @@
 }
 
 
-
 /**
  * Drop database.
  *
@@ -969,10 +967,11 @@
 {
   struct Plugin *plugin = cls;
 
-  if (GNUNET_OK != 
-      GNUNET_POSTGRES_exec (plugin->dbh, "DROP TABLE gn090"))
-    GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, 
-                    "postgres", 
+  if (GNUNET_OK !=
+      GNUNET_POSTGRES_exec (plugin->dbh,
+                            "DROP TABLE gn090"))
+    GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
+                    "postgres",
                     _("Failed to drop table from database.\n"));
 }
 
@@ -1008,7 +1007,8 @@
   api->get_zero_anonymity = &postgres_plugin_get_zero_anonymity;
   api->get_keys = &postgres_plugin_get_keys;
   api->drop = &postgres_plugin_drop;
-  GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datastore-postgres",
+  GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
+                   "datastore-postgres",
                    _("Postgres database running\n"));
   return api;
 }

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2016-03-09 16:57:52 UTC (rev 
36928)
+++ gnunet/src/datastore/test_datastore_api.c   2016-03-14 22:40:04 UTC (rev 
36929)
@@ -197,7 +197,7 @@
   if (GNUNET_OK != success)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Operation %d/%d not successfull: `%s'\n",
+                "Operation %d/%d not successful: `%s'\n",
                 crc->phase,
                 crc->i,
                 msg);
@@ -410,8 +410,7 @@
   {
   case RP_PUT:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Executing `%s' number %u\n",
-                "PUT",
+                "Executing PUT number %u\n",
                 crc->i);
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i),
@@ -426,19 +425,17 @@
   case RP_GET:
     crc->i--;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Executing `%s' number %u\n",
-                "GET",
+                "Executing GET number %u\n",
                 crc->i);
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key,
-                              get_type (crc->i), 1, 1, TIMEOUT, &check_value,
-                              crc);
+                              get_type (crc->i), 1, 1, TIMEOUT,
+                              &check_value, crc);
     break;
   case RP_DEL:
     crc->i--;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Executing `%s' number %u\n",
-                "DEL",
+                "Executing DEL number %u\n",
                 crc->i);
     crc->data = NULL;
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
@@ -449,8 +446,7 @@
     break;
   case RP_DO_DEL:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Executing `%s' number %u\n",
-                "DO_DEL",
+                "Executing DO_DEL number %u\n",
                 crc->i);
     if (crc->i == 0)
     {
@@ -469,8 +465,8 @@
   case RP_DELVALIDATE:
     crc->i--;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Executing `%s' number %u\n",
-                "DEL-VALIDATE", crc->i);
+                "Executing DELVALIDATE number %u\n",
+                crc->i);
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_assert (NULL !=
                    GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]