From: Christian Grothoff Date: Mon, 4 Apr 2011 17:57:21 +0000 (+0000) Subject: renaming, fixes X-Git-Tag: initial-import-from-subversion-38251~18808 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2663c23e2b0944dfb015332f10ff65cfc802588a;p=oweals%2Fgnunet.git renaming, fixes --- diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index dde45f24f..f6b5cd609 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -166,7 +166,13 @@ struct GNUNET_DATASTORE_QueueEntry * Note that the overall struct should end at a * multiple of 64 bits. */ - int32_t was_transmitted; + int was_transmitted; + + /** + * Are we expecting a single message in response to this + * request (and, if it is data, no 'END' message)? + */ + int one_shot; }; @@ -1251,7 +1257,10 @@ process_result_message (void *cls, do_disconnect (h); return; } - GNUNET_DATASTORE_iterate_get_next (h); + if (GNUNET_YES == qe->one_shot) + free_queue_entry (qe); + else + GNUNET_DATASTORE_iterate_get_next (h); return; } dm = (const struct DataMessage*) msg; @@ -1273,6 +1282,8 @@ process_result_message (void *cls, ntohl(dm->anonymity), GNUNET_TIME_absolute_ntoh(dm->expiration), GNUNET_ntohll(dm->uid)); + if (GNUNET_YES == qe->one_shot) + free_queue_entry (qe); } @@ -1310,7 +1321,7 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asked to get random entry in %llu ms\n", + "Asked to get replication entry in %llu ms\n", (unsigned long long) timeout.rel_value); #endif qc.rc.iter = iter; @@ -1322,16 +1333,17 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, { #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Could not create queue entry for GET RANDOM\n"); + "Could not create queue entry for GET REPLICATION\n"); #endif return NULL; } + qe->one_shot = GNUNET_YES; GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# GET RANDOM requests executed"), + gettext_noop ("# GET REPLICATION requests executed"), 1, GNUNET_NO); m = (struct GNUNET_MessageHeader*) &qe[1]; - m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM); + m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION); m->size = htons(sizeof (struct GNUNET_MessageHeader)); process_queue (h); return qe; @@ -1368,6 +1380,7 @@ GNUNET_DATASTORE_iterate_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, struct GetZeroAnonymityMessage *m; union QueueContext qc; + GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to get zero-anonymity entry in %llu ms\n", diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 1d092a619..ba9bc5b93 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -1240,24 +1240,24 @@ handle_update (void *cls, /** - * Handle GET_RANDOM-message. + * Handle GET_REPLICATION-message. * * @param cls closure * @param client identification of the client * @param message the actual message */ static void -handle_get_random (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) +handle_get_replication (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", - "GET_RANDOM"); + "GET_REPLICATION"); #endif GNUNET_STATISTICS_update (stats, - gettext_noop ("# GET RANDOM requests received"), + gettext_noop ("# GET REPLICATION requests received"), 1, GNUNET_NO); GNUNET_SERVER_client_keep (client); @@ -1282,6 +1282,12 @@ handle_get_zero_anonymity (void *cls, enum GNUNET_BLOCK_Type type; type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); + if (type == GNUNET_BLOCK_TYPE_ANY) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", @@ -1706,7 +1712,7 @@ run (void *cls, {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE, sizeof (struct UpdateMessage) }, {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, - {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM, + {&handle_get_replication, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, sizeof(struct GNUNET_MessageHeader) }, {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, sizeof(struct GetZeroAnonymityMessage) }, diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 501c9f292..eca82a6fb 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -1028,12 +1028,14 @@ sqlite_plugin_iter_zero_anonymity (void *cls, sqlite3_stmt *stmt_2; char *q; + GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); now = GNUNET_TIME_absolute_get (); GNUNET_asprintf (&q, "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " - "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND hash < ?2) " + "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND type=%d AND hash < ?2) " "ORDER BY hash DESC LIMIT 1", - (unsigned long long) now.abs_value); + (unsigned long long) now.abs_value, + type); if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK) { LOG_SQLITE (plugin, NULL, @@ -1046,9 +1048,10 @@ sqlite_plugin_iter_zero_anonymity (void *cls, GNUNET_free (q); GNUNET_asprintf (&q, "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " - "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0) " + "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0 AND type=%d) " "ORDER BY prio DESC, hash DESC LIMIT 1", - (unsigned long long) now.abs_value); + (unsigned long long) now.abs_value, + type); if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK) { LOG_SQLITE (plugin, NULL, diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h index 8df61b2f4..372ed633c 100644 --- a/src/include/gnunet_datastore_plugin.h +++ b/src/include/gnunet_datastore_plugin.h @@ -245,7 +245,7 @@ typedef int (*PluginUpdate) (void *cls, * * @param cls closure * @param type entries of which type should be considered? - * Use 0 for any type. + * Myst not be zero (ANY). * @param iter function to call on each matching value; however, * after the first call to "iter", the plugin must wait * until "NextRequest" was called before giving the iterator @@ -293,6 +293,16 @@ struct GNUNET_DATASTORE_PluginFunctions */ PluginPut put; + /** + * Update the priority for a particular key in the datastore. If + * the expiration time in value is different than the time found in + * the datastore, the higher value should be kept. For the + * anonymity level, the lower value is to be used. The specified + * priority should be added to the existing priority, ignoring the + * priority in value. + */ + PluginUpdate update; + /** * Function called by iterators whenever they want the next value; * note that unlike all of the other callbacks, this one does get a @@ -307,6 +317,11 @@ struct GNUNET_DATASTORE_PluginFunctions */ PluginGet get; + /** + * Iterate over content with anonymity level zero. + */ + PluginSelector iter_zero_anonymity; + /** * Function to get a random item with high replication score from * the database, lowering the item's replication score. Returns a @@ -322,21 +337,6 @@ struct GNUNET_DATASTORE_PluginFunctions */ PluginRandomGet expiration_get; - /** - * Update the priority for a particular key in the datastore. If - * the expiration time in value is different than the time found in - * the datastore, the higher value should be kept. For the - * anonymity level, the lower value is to be used. The specified - * priority should be added to the existing priority, ignoring the - * priority in value. - */ - PluginUpdate update; - - /** - * Iterate over content with anonymity level zero. - */ - PluginSelector iter_zero_anonymity; - /** * Delete the database. The next operation is * guaranteed to be unloading of the module. diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 756d2f3be..e18d4ef12 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -322,7 +322,7 @@ GNUNET_DATASTORE_iterate_key (struct GNUNET_DATASTORE_Handle *h, * @param max_queue_size at what queue size should this request be dropped * (if other requests of higher priority are in the queue) * @param timeout how long to wait at most for a response - * @param type allowed type for the operation (ANY for 'all types') + * @param type allowed type for the operation (never zero) * @param iter function to call on a random value; it * will be called once with a value (if available) * and always once with a value of NULL at the end. diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 327b4de51..a485f6712 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -452,7 +452,7 @@ extern "C" /** * Message sent by datastore client to get random data. */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM 98 +#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION 98 /** * Message sent by datastore client to get random data.