diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-04 17:57:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-04 17:57:21 +0000 |
commit | 2663c23e2b0944dfb015332f10ff65cfc802588a (patch) | |
tree | c44540741af69049b6f1f0f7ea1dd574214d5c3c | |
parent | 060e3c202b9c4aed542617ac84b6b3061f51be2b (diff) | |
download | gnunet-2663c23e2b0944dfb015332f10ff65cfc802588a.tar.gz gnunet-2663c23e2b0944dfb015332f10ff65cfc802588a.zip |
renaming, fixes
-rw-r--r-- | src/datastore/datastore_api.c | 25 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 20 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 11 | ||||
-rw-r--r-- | src/include/gnunet_datastore_plugin.h | 32 | ||||
-rw-r--r-- | src/include/gnunet_datastore_service.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 2 |
6 files changed, 57 insertions, 35 deletions
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 | |||
166 | * Note that the overall struct should end at a | 166 | * Note that the overall struct should end at a |
167 | * multiple of 64 bits. | 167 | * multiple of 64 bits. |
168 | */ | 168 | */ |
169 | int32_t was_transmitted; | 169 | int was_transmitted; |
170 | |||
171 | /** | ||
172 | * Are we expecting a single message in response to this | ||
173 | * request (and, if it is data, no 'END' message)? | ||
174 | */ | ||
175 | int one_shot; | ||
170 | 176 | ||
171 | }; | 177 | }; |
172 | 178 | ||
@@ -1251,7 +1257,10 @@ process_result_message (void *cls, | |||
1251 | do_disconnect (h); | 1257 | do_disconnect (h); |
1252 | return; | 1258 | return; |
1253 | } | 1259 | } |
1254 | GNUNET_DATASTORE_iterate_get_next (h); | 1260 | if (GNUNET_YES == qe->one_shot) |
1261 | free_queue_entry (qe); | ||
1262 | else | ||
1263 | GNUNET_DATASTORE_iterate_get_next (h); | ||
1255 | return; | 1264 | return; |
1256 | } | 1265 | } |
1257 | dm = (const struct DataMessage*) msg; | 1266 | dm = (const struct DataMessage*) msg; |
@@ -1273,6 +1282,8 @@ process_result_message (void *cls, | |||
1273 | ntohl(dm->anonymity), | 1282 | ntohl(dm->anonymity), |
1274 | GNUNET_TIME_absolute_ntoh(dm->expiration), | 1283 | GNUNET_TIME_absolute_ntoh(dm->expiration), |
1275 | GNUNET_ntohll(dm->uid)); | 1284 | GNUNET_ntohll(dm->uid)); |
1285 | if (GNUNET_YES == qe->one_shot) | ||
1286 | free_queue_entry (qe); | ||
1276 | } | 1287 | } |
1277 | 1288 | ||
1278 | 1289 | ||
@@ -1310,7 +1321,7 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, | |||
1310 | 1321 | ||
1311 | #if DEBUG_DATASTORE | 1322 | #if DEBUG_DATASTORE |
1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1313 | "Asked to get random entry in %llu ms\n", | 1324 | "Asked to get replication entry in %llu ms\n", |
1314 | (unsigned long long) timeout.rel_value); | 1325 | (unsigned long long) timeout.rel_value); |
1315 | #endif | 1326 | #endif |
1316 | qc.rc.iter = iter; | 1327 | qc.rc.iter = iter; |
@@ -1322,16 +1333,17 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, | |||
1322 | { | 1333 | { |
1323 | #if DEBUG_DATASTORE | 1334 | #if DEBUG_DATASTORE |
1324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1325 | "Could not create queue entry for GET RANDOM\n"); | 1336 | "Could not create queue entry for GET REPLICATION\n"); |
1326 | #endif | 1337 | #endif |
1327 | return NULL; | 1338 | return NULL; |
1328 | } | 1339 | } |
1340 | qe->one_shot = GNUNET_YES; | ||
1329 | GNUNET_STATISTICS_update (h->stats, | 1341 | GNUNET_STATISTICS_update (h->stats, |
1330 | gettext_noop ("# GET RANDOM requests executed"), | 1342 | gettext_noop ("# GET REPLICATION requests executed"), |
1331 | 1, | 1343 | 1, |
1332 | GNUNET_NO); | 1344 | GNUNET_NO); |
1333 | m = (struct GNUNET_MessageHeader*) &qe[1]; | 1345 | m = (struct GNUNET_MessageHeader*) &qe[1]; |
1334 | m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM); | 1346 | m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION); |
1335 | m->size = htons(sizeof (struct GNUNET_MessageHeader)); | 1347 | m->size = htons(sizeof (struct GNUNET_MessageHeader)); |
1336 | process_queue (h); | 1348 | process_queue (h); |
1337 | return qe; | 1349 | return qe; |
@@ -1368,6 +1380,7 @@ GNUNET_DATASTORE_iterate_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, | |||
1368 | struct GetZeroAnonymityMessage *m; | 1380 | struct GetZeroAnonymityMessage *m; |
1369 | union QueueContext qc; | 1381 | union QueueContext qc; |
1370 | 1382 | ||
1383 | GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); | ||
1371 | #if DEBUG_DATASTORE | 1384 | #if DEBUG_DATASTORE |
1372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1373 | "Asked to get zero-anonymity entry in %llu ms\n", | 1386 | "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, | |||
1240 | 1240 | ||
1241 | 1241 | ||
1242 | /** | 1242 | /** |
1243 | * Handle GET_RANDOM-message. | 1243 | * Handle GET_REPLICATION-message. |
1244 | * | 1244 | * |
1245 | * @param cls closure | 1245 | * @param cls closure |
1246 | * @param client identification of the client | 1246 | * @param client identification of the client |
1247 | * @param message the actual message | 1247 | * @param message the actual message |
1248 | */ | 1248 | */ |
1249 | static void | 1249 | static void |
1250 | handle_get_random (void *cls, | 1250 | handle_get_replication (void *cls, |
1251 | struct GNUNET_SERVER_Client *client, | 1251 | struct GNUNET_SERVER_Client *client, |
1252 | const struct GNUNET_MessageHeader *message) | 1252 | const struct GNUNET_MessageHeader *message) |
1253 | { | 1253 | { |
1254 | #if DEBUG_DATASTORE | 1254 | #if DEBUG_DATASTORE |
1255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1256 | "Processing `%s' request\n", | 1256 | "Processing `%s' request\n", |
1257 | "GET_RANDOM"); | 1257 | "GET_REPLICATION"); |
1258 | #endif | 1258 | #endif |
1259 | GNUNET_STATISTICS_update (stats, | 1259 | GNUNET_STATISTICS_update (stats, |
1260 | gettext_noop ("# GET RANDOM requests received"), | 1260 | gettext_noop ("# GET REPLICATION requests received"), |
1261 | 1, | 1261 | 1, |
1262 | GNUNET_NO); | 1262 | GNUNET_NO); |
1263 | GNUNET_SERVER_client_keep (client); | 1263 | GNUNET_SERVER_client_keep (client); |
@@ -1282,6 +1282,12 @@ handle_get_zero_anonymity (void *cls, | |||
1282 | enum GNUNET_BLOCK_Type type; | 1282 | enum GNUNET_BLOCK_Type type; |
1283 | 1283 | ||
1284 | type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); | 1284 | type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); |
1285 | if (type == GNUNET_BLOCK_TYPE_ANY) | ||
1286 | { | ||
1287 | GNUNET_break (0); | ||
1288 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1289 | return; | ||
1290 | } | ||
1285 | #if DEBUG_DATASTORE | 1291 | #if DEBUG_DATASTORE |
1286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1292 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1287 | "Processing `%s' request\n", | 1293 | "Processing `%s' request\n", |
@@ -1706,7 +1712,7 @@ run (void *cls, | |||
1706 | {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE, | 1712 | {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE, |
1707 | sizeof (struct UpdateMessage) }, | 1713 | sizeof (struct UpdateMessage) }, |
1708 | {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, | 1714 | {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, |
1709 | {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM, | 1715 | {&handle_get_replication, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, |
1710 | sizeof(struct GNUNET_MessageHeader) }, | 1716 | sizeof(struct GNUNET_MessageHeader) }, |
1711 | {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, | 1717 | {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, |
1712 | sizeof(struct GetZeroAnonymityMessage) }, | 1718 | 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, | |||
1028 | sqlite3_stmt *stmt_2; | 1028 | sqlite3_stmt *stmt_2; |
1029 | char *q; | 1029 | char *q; |
1030 | 1030 | ||
1031 | GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); | ||
1031 | now = GNUNET_TIME_absolute_get (); | 1032 | now = GNUNET_TIME_absolute_get (); |
1032 | GNUNET_asprintf (&q, | 1033 | GNUNET_asprintf (&q, |
1033 | "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " | 1034 | "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " |
1034 | "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND hash < ?2) " | 1035 | "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND type=%d AND hash < ?2) " |
1035 | "ORDER BY hash DESC LIMIT 1", | 1036 | "ORDER BY hash DESC LIMIT 1", |
1036 | (unsigned long long) now.abs_value); | 1037 | (unsigned long long) now.abs_value, |
1038 | type); | ||
1037 | if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK) | 1039 | if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK) |
1038 | { | 1040 | { |
1039 | LOG_SQLITE (plugin, NULL, | 1041 | LOG_SQLITE (plugin, NULL, |
@@ -1046,9 +1048,10 @@ sqlite_plugin_iter_zero_anonymity (void *cls, | |||
1046 | GNUNET_free (q); | 1048 | GNUNET_free (q); |
1047 | GNUNET_asprintf (&q, | 1049 | GNUNET_asprintf (&q, |
1048 | "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " | 1050 | "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " |
1049 | "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0) " | 1051 | "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0 AND type=%d) " |
1050 | "ORDER BY prio DESC, hash DESC LIMIT 1", | 1052 | "ORDER BY prio DESC, hash DESC LIMIT 1", |
1051 | (unsigned long long) now.abs_value); | 1053 | (unsigned long long) now.abs_value, |
1054 | type); | ||
1052 | if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK) | 1055 | if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK) |
1053 | { | 1056 | { |
1054 | LOG_SQLITE (plugin, NULL, | 1057 | 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, | |||
245 | * | 245 | * |
246 | * @param cls closure | 246 | * @param cls closure |
247 | * @param type entries of which type should be considered? | 247 | * @param type entries of which type should be considered? |
248 | * Use 0 for any type. | 248 | * Myst not be zero (ANY). |
249 | * @param iter function to call on each matching value; however, | 249 | * @param iter function to call on each matching value; however, |
250 | * after the first call to "iter", the plugin must wait | 250 | * after the first call to "iter", the plugin must wait |
251 | * until "NextRequest" was called before giving the iterator | 251 | * until "NextRequest" was called before giving the iterator |
@@ -294,6 +294,16 @@ struct GNUNET_DATASTORE_PluginFunctions | |||
294 | PluginPut put; | 294 | PluginPut put; |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * Update the priority for a particular key in the datastore. If | ||
298 | * the expiration time in value is different than the time found in | ||
299 | * the datastore, the higher value should be kept. For the | ||
300 | * anonymity level, the lower value is to be used. The specified | ||
301 | * priority should be added to the existing priority, ignoring the | ||
302 | * priority in value. | ||
303 | */ | ||
304 | PluginUpdate update; | ||
305 | |||
306 | /** | ||
297 | * Function called by iterators whenever they want the next value; | 307 | * Function called by iterators whenever they want the next value; |
298 | * note that unlike all of the other callbacks, this one does get a | 308 | * note that unlike all of the other callbacks, this one does get a |
299 | * the "next_cls" closure which is usually different from the "cls" | 309 | * the "next_cls" closure which is usually different from the "cls" |
@@ -308,6 +318,11 @@ struct GNUNET_DATASTORE_PluginFunctions | |||
308 | PluginGet get; | 318 | PluginGet get; |
309 | 319 | ||
310 | /** | 320 | /** |
321 | * Iterate over content with anonymity level zero. | ||
322 | */ | ||
323 | PluginSelector iter_zero_anonymity; | ||
324 | |||
325 | /** | ||
311 | * Function to get a random item with high replication score from | 326 | * Function to get a random item with high replication score from |
312 | * the database, lowering the item's replication score. Returns a | 327 | * the database, lowering the item's replication score. Returns a |
313 | * single, not expired, random item from those with the highest | 328 | * single, not expired, random item from those with the highest |
@@ -323,21 +338,6 @@ struct GNUNET_DATASTORE_PluginFunctions | |||
323 | PluginRandomGet expiration_get; | 338 | PluginRandomGet expiration_get; |
324 | 339 | ||
325 | /** | 340 | /** |
326 | * Update the priority for a particular key in the datastore. If | ||
327 | * the expiration time in value is different than the time found in | ||
328 | * the datastore, the higher value should be kept. For the | ||
329 | * anonymity level, the lower value is to be used. The specified | ||
330 | * priority should be added to the existing priority, ignoring the | ||
331 | * priority in value. | ||
332 | */ | ||
333 | PluginUpdate update; | ||
334 | |||
335 | /** | ||
336 | * Iterate over content with anonymity level zero. | ||
337 | */ | ||
338 | PluginSelector iter_zero_anonymity; | ||
339 | |||
340 | /** | ||
341 | * Delete the database. The next operation is | 341 | * Delete the database. The next operation is |
342 | * guaranteed to be unloading of the module. | 342 | * guaranteed to be unloading of the module. |
343 | */ | 343 | */ |
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, | |||
322 | * @param max_queue_size at what queue size should this request be dropped | 322 | * @param max_queue_size at what queue size should this request be dropped |
323 | * (if other requests of higher priority are in the queue) | 323 | * (if other requests of higher priority are in the queue) |
324 | * @param timeout how long to wait at most for a response | 324 | * @param timeout how long to wait at most for a response |
325 | * @param type allowed type for the operation (ANY for 'all types') | 325 | * @param type allowed type for the operation (never zero) |
326 | * @param iter function to call on a random value; it | 326 | * @param iter function to call on a random value; it |
327 | * will be called once with a value (if available) | 327 | * will be called once with a value (if available) |
328 | * and always once with a value of NULL at the end. | 328 | * 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" | |||
452 | /** | 452 | /** |
453 | * Message sent by datastore client to get random data. | 453 | * Message sent by datastore client to get random data. |
454 | */ | 454 | */ |
455 | #define GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM 98 | 455 | #define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION 98 |
456 | 456 | ||
457 | /** | 457 | /** |
458 | * Message sent by datastore client to get random data. | 458 | * Message sent by datastore client to get random data. |