From 4c1791f13283df27338cd877e2087d519aaab05e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 14 Mar 2016 22:40:04 +0000 Subject: [PATCH] -bugfix, adding comments, fixing indent --- src/datastore/gnunet-service-datastore.c | 141 ++++++++++----- src/datastore/plugin_datastore_postgres.c | 204 +++++++++++----------- src/datastore/test_datastore_api.c | 22 +-- 3 files changed, 205 insertions(+), 162 deletions(-) diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index ba8baf719..4979f4482 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -681,7 +681,8 @@ handle_reserve (void *cls, struct GNUNET_SERVER_Client *client, 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 @@ handle_release_reserve (void *cls, 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 @@ execute_put (struct PutContext *pc) } +/** + * + * @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 @@ check_present (void *cls, 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 @@ check_present (void *cls, * @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 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client, 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 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client, * @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 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, } 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 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, } +/** + * 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 @@ update_continuation (void *cls, * @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 @@ handle_update (void *cls, struct GNUNET_SERVER_Client *client, 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 @@ handle_update (void *cls, struct GNUNET_SERVER_Client *client, * @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 @@ handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, 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 @@ handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, * @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,28 +1226,45 @@ handle_get_zero_anonymity (void *cls, struct GNUNET_SERVER_Client *client, 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); } /** * 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 @@ remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size, 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 @@ remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size, * @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 @@ handle_remove (void *cls, struct GNUNET_SERVER_Client *client, * @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); } diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 0c51e8b7d..faf988517 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -78,7 +78,7 @@ init_connection (struct Plugin *plugin) 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 @@ init_connection (struct Plugin *plugin) " 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 @@ postgres_plugin_estimate_size (void *cls, unsigned long long *estimate) "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 @@ postgres_plugin_estimate_size (void *cls, unsigned long long *estimate) * @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 @@ postgres_plugin_put (void *cls, "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 @@ postgres_plugin_put (void *cls, * @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 @@ process_result (struct Plugin *plugin, }; 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 @@ process_result (struct Plugin *plugin, 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 @@ process_result (struct Plugin *plugin, 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 @@ process_result (struct Plugin *plugin, 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 @@ process_result (struct Plugin *plugin, 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 @@ process_result (struct Plugin *plugin, * @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 @@ postgres_plugin_get_key (void *cls, { 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 @@ postgres_plugin_get_key (void *cls, } 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 @@ postgres_plugin_get_key (void *cls, { 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 @@ postgres_plugin_get_key (void *cls, } 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 @@ postgres_plugin_get_key (void *cls, } 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 @@ postgres_plugin_get_key (void *cls, 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 @@ postgres_plugin_get_key (void *cls, { 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 @@ postgres_plugin_get_key (void *cls, } 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 @@ postgres_plugin_get_key (void *cls, { 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 @@ postgres_plugin_get_key (void *cls, } 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 @@ postgres_plugin_get_key (void *cls, } process_result (plugin, proc, - proc_cls, - ret, + proc_cls, + ret, __FILE__, __LINE__); } @@ -675,15 +675,15 @@ postgres_plugin_get_key (void *cls, * @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 @@ postgres_plugin_get_zero_anonymity (void *cls, "select_non_anonymous", params); - process_result (plugin, + process_result (plugin, proc, proc_cls, ret, __FILE__, __LINE__); @@ -739,7 +739,7 @@ struct ReplCtx * @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 @@ repl_proc (void *cls, 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 @@ repl_proc (void *cls, 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 @@ repl_proc (void *cls, "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 @@ repl_proc (void *cls, * @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 @@ postgres_plugin_get_replication (void *cls, 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 @@ postgres_plugin_get_replication (void *cls, * @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 @@ postgres_plugin_get_expiration (void *cls, * @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 @@ postgres_plugin_update (void *cls, 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 @@ postgres_plugin_update (void *cls, 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 @@ postgres_plugin_get_keys (void *cls, 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;idbh, "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 @@ libgnunet_plugin_datastore_postgres_init (void *cls) 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; } diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index c50543210..12f2ef762 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -197,7 +197,7 @@ check_success (void *cls, 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 @@ run_continuation (void *cls, { 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 @@ run_continuation (void *cls, 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 @@ run_continuation (void *cls, 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 @@ run_continuation (void *cls, 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, -- 2.25.1