diff options
author | xrs <xrs@mail36.net> | 2017-03-12 17:50:29 +0100 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2017-03-12 17:50:29 +0100 |
commit | e8f3e87e15bad4a64e2911c0e70760672d574cff (patch) | |
tree | 47d9d142bf16fe47fac4828b0657d20703130412 /src | |
parent | 254362f9b8511629cecd433ee260ff3d1e156c28 (diff) | |
parent | a2ac01f46c4d57034b5d40201b29701ff95b456a (diff) | |
download | gnunet-e8f3e87e15bad4a64e2911c0e70760672d574cff.tar.gz gnunet-e8f3e87e15bad4a64e2911c0e70760672d574cff.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r-- | src/namecache/Makefile.am | 2 | ||||
-rw-r--r-- | src/namecache/plugin_namecache_sqlite.c | 215 | ||||
-rw-r--r-- | src/namestore/Makefile.am | 1 | ||||
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 7 | ||||
-rw-r--r-- | src/set/gnunet-service-set_intersection.h | 79 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.h | 239 |
6 files changed, 442 insertions, 101 deletions
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am index 89d7bffee..d379b2602 100644 --- a/src/namecache/Makefile.am +++ b/src/namecache/Makefile.am | |||
@@ -121,6 +121,7 @@ libgnunet_plugin_namecache_sqlite_la_SOURCES = \ | |||
121 | plugin_namecache_sqlite.c | 121 | plugin_namecache_sqlite.c |
122 | libgnunet_plugin_namecache_sqlite_la_LIBADD = \ | 122 | libgnunet_plugin_namecache_sqlite_la_LIBADD = \ |
123 | libgnunetnamecache.la \ | 123 | libgnunetnamecache.la \ |
124 | $(top_builddir)/src/sq/libgnunetsq.la \ | ||
124 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 125 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
125 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ | 126 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ |
126 | $(LTLIBINTL) | 127 | $(LTLIBINTL) |
@@ -172,4 +173,3 @@ EXTRA_DIST = \ | |||
172 | test_plugin_namecache_sqlite.conf \ | 173 | test_plugin_namecache_sqlite.conf \ |
173 | test_plugin_namecache_postgres.conf \ | 174 | test_plugin_namecache_postgres.conf \ |
174 | test_plugin_namecache_flat.conf | 175 | test_plugin_namecache_flat.conf |
175 | |||
diff --git a/src/namecache/plugin_namecache_sqlite.c b/src/namecache/plugin_namecache_sqlite.c index fdce899fa..2f7b2a981 100644 --- a/src/namecache/plugin_namecache_sqlite.c +++ b/src/namecache/plugin_namecache_sqlite.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_sq_lib.h" | ||
28 | #include "gnunet_namecache_plugin.h" | 29 | #include "gnunet_namecache_plugin.h" |
29 | #include "gnunet_namecache_service.h" | 30 | #include "gnunet_namecache_service.h" |
30 | #include "gnunet_gnsrecord_lib.h" | 31 | #include "gnunet_gnsrecord_lib.h" |
@@ -241,25 +242,28 @@ database_setup (struct Plugin *plugin) | |||
241 | sqlite3_finalize (stmt); | 242 | sqlite3_finalize (stmt); |
242 | create_indices (plugin->dbh); | 243 | create_indices (plugin->dbh); |
243 | 244 | ||
244 | if ((sq_prepare | 245 | if ( (SQLITE_OK != |
245 | (plugin->dbh, | 246 | sq_prepare (plugin->dbh, |
246 | "INSERT INTO ns096blocks (query,block,expiration_time) VALUES (?, ?, ?)", | 247 | "INSERT INTO ns096blocks (query,block,expiration_time) VALUES (?, ?, ?)", |
247 | &plugin->cache_block) != SQLITE_OK) || | 248 | &plugin->cache_block)) || |
248 | (sq_prepare | 249 | (SQLITE_OK != |
249 | (plugin->dbh, | 250 | sq_prepare (plugin->dbh, |
250 | "DELETE FROM ns096blocks WHERE expiration_time<?", | 251 | "DELETE FROM ns096blocks WHERE expiration_time<?", |
251 | &plugin->expire_blocks) != SQLITE_OK) || | 252 | &plugin->expire_blocks)) || |
252 | (sq_prepare | 253 | (SQLITE_OK != |
253 | (plugin->dbh, | 254 | sq_prepare (plugin->dbh, |
254 | "DELETE FROM ns096blocks WHERE query=? AND expiration_time<=?", | 255 | "DELETE FROM ns096blocks WHERE query=? AND expiration_time<=?", |
255 | &plugin->delete_block) != SQLITE_OK) || | 256 | &plugin->delete_block)) || |
256 | (sq_prepare | 257 | (SQLITE_OK != |
257 | (plugin->dbh, | 258 | sq_prepare (plugin->dbh, |
258 | "SELECT block FROM ns096blocks WHERE query=? ORDER BY expiration_time DESC LIMIT 1", | 259 | "SELECT block FROM ns096blocks WHERE query=? " |
259 | &plugin->lookup_block) != SQLITE_OK) | 260 | "ORDER BY expiration_time DESC LIMIT 1", |
261 | &plugin->lookup_block) ) | ||
260 | ) | 262 | ) |
261 | { | 263 | { |
262 | LOG_SQLITE (plugin,GNUNET_ERROR_TYPE_ERROR, "precompiling"); | 264 | LOG_SQLITE (plugin, |
265 | GNUNET_ERROR_TYPE_ERROR, | ||
266 | "precompiling"); | ||
263 | return GNUNET_SYSERR; | 267 | return GNUNET_SYSERR; |
264 | } | 268 | } |
265 | return GNUNET_OK; | 269 | return GNUNET_OK; |
@@ -319,35 +323,41 @@ static void | |||
319 | namecache_sqlite_expire_blocks (struct Plugin *plugin) | 323 | namecache_sqlite_expire_blocks (struct Plugin *plugin) |
320 | { | 324 | { |
321 | struct GNUNET_TIME_Absolute now; | 325 | struct GNUNET_TIME_Absolute now; |
326 | struct GNUNET_SQ_QueryParam params[] = { | ||
327 | GNUNET_SQ_query_param_absolute_time (&now), | ||
328 | GNUNET_SQ_query_param_end | ||
329 | }; | ||
322 | int n; | 330 | int n; |
323 | 331 | ||
324 | now = GNUNET_TIME_absolute_get (); | 332 | now = GNUNET_TIME_absolute_get (); |
325 | if (SQLITE_OK != sqlite3_bind_int64 (plugin->expire_blocks, | 333 | if (GNUNET_OK != |
326 | 1, now.abs_value_us)) | 334 | GNUNET_SQ_bind (plugin->expire_blocks, |
335 | params)) | ||
327 | { | 336 | { |
328 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 337 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
329 | "sqlite3_bind_XXXX"); | 338 | "sqlite3_bind_XXXX"); |
330 | if (SQLITE_OK != sqlite3_reset (plugin->expire_blocks)) | 339 | GNUNET_SQ_reset (plugin->dbh, |
331 | LOG_SQLITE (plugin, | 340 | plugin->expire_blocks); |
332 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
333 | "sqlite3_reset"); | ||
334 | return; | 341 | return; |
335 | } | 342 | } |
336 | n = sqlite3_step (plugin->expire_blocks); | 343 | n = sqlite3_step (plugin->expire_blocks); |
337 | if (SQLITE_OK != sqlite3_reset (plugin->expire_blocks)) | 344 | GNUNET_SQ_reset (plugin->dbh, |
338 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 345 | plugin->expire_blocks); |
339 | "sqlite3_reset"); | ||
340 | switch (n) | 346 | switch (n) |
341 | { | 347 | { |
342 | case SQLITE_DONE: | 348 | case SQLITE_DONE: |
343 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Records expired\n"); | 349 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
350 | "sqlite", | ||
351 | "Records expired\n"); | ||
344 | return; | 352 | return; |
345 | case SQLITE_BUSY: | 353 | case SQLITE_BUSY: |
346 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 354 | LOG_SQLITE (plugin, |
355 | GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | ||
347 | "sqlite3_step"); | 356 | "sqlite3_step"); |
348 | return; | 357 | return; |
349 | default: | 358 | default: |
350 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 359 | LOG_SQLITE (plugin, |
360 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
351 | "sqlite3_step"); | 361 | "sqlite3_step"); |
352 | return; | 362 | return; |
353 | } | 363 | } |
@@ -368,8 +378,21 @@ namecache_sqlite_cache_block (void *cls, | |||
368 | struct Plugin *plugin = cls; | 378 | struct Plugin *plugin = cls; |
369 | struct GNUNET_HashCode query; | 379 | struct GNUNET_HashCode query; |
370 | struct GNUNET_TIME_Absolute expiration; | 380 | struct GNUNET_TIME_Absolute expiration; |
371 | int64_t dval; | 381 | size_t block_size = ntohl (block->purpose.size) + |
372 | size_t block_size; | 382 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + |
383 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature); | ||
384 | struct GNUNET_SQ_QueryParam del_params[] = { | ||
385 | GNUNET_SQ_query_param_auto_from_type (&query), | ||
386 | GNUNET_SQ_query_param_absolute_time (&expiration), | ||
387 | GNUNET_SQ_query_param_end | ||
388 | }; | ||
389 | struct GNUNET_SQ_QueryParam ins_params[] = { | ||
390 | GNUNET_SQ_query_param_auto_from_type (&query), | ||
391 | GNUNET_SQ_query_param_fixed_size (block, | ||
392 | block_size), | ||
393 | GNUNET_SQ_query_param_absolute_time (&expiration), | ||
394 | GNUNET_SQ_query_param_end | ||
395 | }; | ||
373 | int n; | 396 | int n; |
374 | 397 | ||
375 | namecache_sqlite_expire_blocks (plugin); | 398 | namecache_sqlite_expire_blocks (plugin); |
@@ -377,12 +400,6 @@ namecache_sqlite_cache_block (void *cls, | |||
377 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), | 400 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), |
378 | &query); | 401 | &query); |
379 | expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); | 402 | expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); |
380 | dval = (int64_t) expiration.abs_value_us; | ||
381 | if (dval < 0) | ||
382 | dval = INT64_MAX; | ||
383 | block_size = ntohl (block->purpose.size) + | ||
384 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + | ||
385 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature); | ||
386 | if (block_size > 64 * 65536) | 403 | if (block_size > 64 * 65536) |
387 | { | 404 | { |
388 | GNUNET_break (0); | 405 | GNUNET_break (0); |
@@ -390,61 +407,48 @@ namecache_sqlite_cache_block (void *cls, | |||
390 | } | 407 | } |
391 | 408 | ||
392 | /* delete old version of the block */ | 409 | /* delete old version of the block */ |
393 | if ( (SQLITE_OK != | 410 | if (GNUNET_OK != |
394 | sqlite3_bind_blob (plugin->delete_block, 1, | 411 | GNUNET_SQ_bind (plugin->delete_block, |
395 | &query, sizeof (struct GNUNET_HashCode), | 412 | del_params)) |
396 | SQLITE_STATIC)) || | ||
397 | (SQLITE_OK != | ||
398 | sqlite3_bind_int64 (plugin->delete_block, | ||
399 | 2, dval)) ) | ||
400 | { | 413 | { |
401 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 414 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
402 | "sqlite3_bind_XXXX"); | 415 | "sqlite3_bind_XXXX"); |
403 | if (SQLITE_OK != sqlite3_reset (plugin->delete_block)) | 416 | GNUNET_SQ_reset (plugin->dbh, |
404 | LOG_SQLITE (plugin, | 417 | plugin->delete_block); |
405 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
406 | "sqlite3_reset"); | ||
407 | return GNUNET_SYSERR; | 418 | return GNUNET_SYSERR; |
408 | } | 419 | } |
409 | n = sqlite3_step (plugin->delete_block); | 420 | n = sqlite3_step (plugin->delete_block); |
410 | switch (n) | 421 | switch (n) |
411 | { | 422 | { |
412 | case SQLITE_DONE: | 423 | case SQLITE_DONE: |
413 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Old block deleted\n"); | 424 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
425 | "sqlite", | ||
426 | "Old block deleted\n"); | ||
414 | break; | 427 | break; |
415 | case SQLITE_BUSY: | 428 | case SQLITE_BUSY: |
416 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 429 | LOG_SQLITE (plugin, |
430 | GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | ||
417 | "sqlite3_step"); | 431 | "sqlite3_step"); |
418 | break; | 432 | break; |
419 | default: | 433 | default: |
420 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 434 | LOG_SQLITE (plugin, |
435 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
421 | "sqlite3_step"); | 436 | "sqlite3_step"); |
422 | break; | 437 | break; |
423 | } | 438 | } |
424 | if (SQLITE_OK != sqlite3_reset (plugin->delete_block)) | 439 | GNUNET_SQ_reset (plugin->dbh, |
425 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 440 | plugin->delete_block); |
426 | "sqlite3_reset"); | ||
427 | 441 | ||
428 | /* insert new version of the block */ | 442 | /* insert new version of the block */ |
429 | if ((SQLITE_OK != | 443 | if (GNUNET_OK != |
430 | sqlite3_bind_blob (plugin->cache_block, 1, | 444 | GNUNET_SQ_bind (plugin->cache_block, |
431 | &query, sizeof (struct GNUNET_HashCode), | 445 | ins_params)) |
432 | SQLITE_STATIC)) || | ||
433 | (SQLITE_OK != | ||
434 | sqlite3_bind_blob (plugin->cache_block, 2, | ||
435 | block, block_size, | ||
436 | SQLITE_STATIC)) || | ||
437 | (SQLITE_OK != | ||
438 | sqlite3_bind_int64 (plugin->cache_block, 3, | ||
439 | dval))) | ||
440 | { | 446 | { |
441 | LOG_SQLITE (plugin, | 447 | LOG_SQLITE (plugin, |
442 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 448 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
443 | "sqlite3_bind_XXXX"); | 449 | "sqlite3_bind_XXXX"); |
444 | if (SQLITE_OK != sqlite3_reset (plugin->cache_block)) | 450 | GNUNET_SQ_reset (plugin->dbh, |
445 | LOG_SQLITE (plugin, | 451 | plugin->cache_block); |
446 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
447 | "sqlite3_reset"); | ||
448 | return GNUNET_SYSERR; | 452 | return GNUNET_SYSERR; |
449 | 453 | ||
450 | } | 454 | } |
@@ -452,9 +456,8 @@ namecache_sqlite_cache_block (void *cls, | |||
452 | "Caching block under derived key `%s'\n", | 456 | "Caching block under derived key `%s'\n", |
453 | GNUNET_h2s_full (&query)); | 457 | GNUNET_h2s_full (&query)); |
454 | n = sqlite3_step (plugin->cache_block); | 458 | n = sqlite3_step (plugin->cache_block); |
455 | if (SQLITE_OK != sqlite3_reset (plugin->cache_block)) | 459 | GNUNET_SQ_reset (plugin->dbh, |
456 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 460 | plugin->cache_block); |
457 | "sqlite3_reset"); | ||
458 | switch (n) | 461 | switch (n) |
459 | { | 462 | { |
460 | case SQLITE_DONE: | 463 | case SQLITE_DONE: |
@@ -462,11 +465,13 @@ namecache_sqlite_cache_block (void *cls, | |||
462 | "Record stored\n"); | 465 | "Record stored\n"); |
463 | return GNUNET_OK; | 466 | return GNUNET_OK; |
464 | case SQLITE_BUSY: | 467 | case SQLITE_BUSY: |
465 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 468 | LOG_SQLITE (plugin, |
469 | GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | ||
466 | "sqlite3_step"); | 470 | "sqlite3_step"); |
467 | return GNUNET_NO; | 471 | return GNUNET_NO; |
468 | default: | 472 | default: |
469 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 473 | LOG_SQLITE (plugin, |
474 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
470 | "sqlite3_step"); | 475 | "sqlite3_step"); |
471 | return GNUNET_SYSERR; | 476 | return GNUNET_SYSERR; |
472 | } | 477 | } |
@@ -486,45 +491,63 @@ namecache_sqlite_cache_block (void *cls, | |||
486 | static int | 491 | static int |
487 | namecache_sqlite_lookup_block (void *cls, | 492 | namecache_sqlite_lookup_block (void *cls, |
488 | const struct GNUNET_HashCode *query, | 493 | const struct GNUNET_HashCode *query, |
489 | GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls) | 494 | GNUNET_NAMECACHE_BlockCallback iter, |
495 | void *iter_cls) | ||
490 | { | 496 | { |
491 | struct Plugin *plugin = cls; | 497 | struct Plugin *plugin = cls; |
492 | int ret; | 498 | int ret; |
493 | int sret; | 499 | int sret; |
494 | size_t block_size; | 500 | size_t block_size; |
495 | const struct GNUNET_GNSRECORD_Block *block; | 501 | const struct GNUNET_GNSRECORD_Block *block; |
502 | struct GNUNET_SQ_QueryParam params[] = { | ||
503 | GNUNET_SQ_query_param_auto_from_type (query), | ||
504 | GNUNET_SQ_query_param_end | ||
505 | }; | ||
506 | struct GNUNET_SQ_ResultSpec rs[] = { | ||
507 | GNUNET_SQ_result_spec_variable_size ((void **) &block, | ||
508 | &block_size), | ||
509 | GNUNET_SQ_result_spec_end | ||
510 | }; | ||
496 | 511 | ||
497 | if (SQLITE_OK != sqlite3_bind_blob (plugin->lookup_block, 1, | 512 | if (GNUNET_OK != |
498 | query, sizeof (struct GNUNET_HashCode), | 513 | GNUNET_SQ_bind (plugin->lookup_block, |
499 | SQLITE_STATIC)) | 514 | params)) |
500 | { | 515 | { |
501 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 516 | LOG_SQLITE (plugin, |
517 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
502 | "sqlite3_bind_XXXX"); | 518 | "sqlite3_bind_XXXX"); |
503 | if (SQLITE_OK != sqlite3_reset (plugin->lookup_block)) | 519 | GNUNET_SQ_reset (plugin->dbh, |
504 | LOG_SQLITE (plugin, | 520 | plugin->lookup_block); |
505 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
506 | "sqlite3_reset"); | ||
507 | return GNUNET_SYSERR; | 521 | return GNUNET_SYSERR; |
508 | } | 522 | } |
509 | ret = GNUNET_NO; | 523 | ret = GNUNET_NO; |
510 | if (SQLITE_ROW == (sret = sqlite3_step (plugin->lookup_block))) | 524 | if (SQLITE_ROW == |
525 | (sret = sqlite3_step (plugin->lookup_block))) | ||
511 | { | 526 | { |
512 | block = sqlite3_column_blob (plugin->lookup_block, 0); | 527 | if (GNUNET_OK != |
513 | block_size = sqlite3_column_bytes (plugin->lookup_block, 0); | 528 | GNUNET_SQ_extract_result (plugin->lookup_block, |
514 | if ( (block_size < sizeof (struct GNUNET_GNSRECORD_Block)) || | 529 | rs)) |
515 | (ntohl (block->purpose.size) + | ||
516 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + | ||
517 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature) != block_size) ) | ||
518 | { | 530 | { |
519 | GNUNET_break (0); | 531 | GNUNET_break (0); |
520 | ret = GNUNET_SYSERR; | 532 | ret = GNUNET_SYSERR; |
521 | } | 533 | } |
534 | else if ( (block_size < sizeof (struct GNUNET_GNSRECORD_Block)) || | ||
535 | (ntohl (block->purpose.size) + | ||
536 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + | ||
537 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature) != block_size) ) | ||
538 | { | ||
539 | GNUNET_break (0); | ||
540 | GNUNET_SQ_cleanup_result (rs); | ||
541 | ret = GNUNET_SYSERR; | ||
542 | } | ||
522 | else | 543 | else |
523 | { | 544 | { |
524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
525 | "Found block under derived key `%s'\n", | 546 | "Found block under derived key `%s'\n", |
526 | GNUNET_h2s_full (query)); | 547 | GNUNET_h2s_full (query)); |
527 | iter (iter_cls, block); | 548 | iter (iter_cls, |
549 | block); | ||
550 | GNUNET_SQ_cleanup_result (rs); | ||
528 | ret = GNUNET_YES; | 551 | ret = GNUNET_YES; |
529 | } | 552 | } |
530 | } | 553 | } |
@@ -532,7 +555,9 @@ namecache_sqlite_lookup_block (void *cls, | |||
532 | { | 555 | { |
533 | if (SQLITE_DONE != sret) | 556 | if (SQLITE_DONE != sret) |
534 | { | 557 | { |
535 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step"); | 558 | LOG_SQLITE (plugin, |
559 | GNUNET_ERROR_TYPE_ERROR, | ||
560 | "sqlite_step"); | ||
536 | ret = GNUNET_SYSERR; | 561 | ret = GNUNET_SYSERR; |
537 | } | 562 | } |
538 | else | 563 | else |
@@ -542,10 +567,8 @@ namecache_sqlite_lookup_block (void *cls, | |||
542 | GNUNET_h2s_full (query)); | 567 | GNUNET_h2s_full (query)); |
543 | } | 568 | } |
544 | } | 569 | } |
545 | if (SQLITE_OK != sqlite3_reset (plugin->lookup_block)) | 570 | GNUNET_SQ_reset (plugin->dbh, |
546 | LOG_SQLITE (plugin, | 571 | plugin->lookup_block); |
547 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
548 | "sqlite3_reset"); | ||
549 | return ret; | 572 | return ret; |
550 | } | 573 | } |
551 | 574 | ||
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index e9b0f179a..de46e9c89 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -189,6 +189,7 @@ libgnunet_plugin_namestore_sqlite_la_SOURCES = \ | |||
189 | plugin_namestore_sqlite.c | 189 | plugin_namestore_sqlite.c |
190 | libgnunet_plugin_namestore_sqlite_la_LIBADD = \ | 190 | libgnunet_plugin_namestore_sqlite_la_LIBADD = \ |
191 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 191 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
192 | $(top_builddir)/src/sq/libgnunetsq.la \ | ||
192 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 193 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
193 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ | 194 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ |
194 | $(LTLIBINTL) | 195 | $(LTLIBINTL) |
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index b298f7b41..bb369a81f 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -849,10 +849,6 @@ static void | |||
849 | begin_bf_exchange (struct Operation *op) | 849 | begin_bf_exchange (struct Operation *op) |
850 | { | 850 | { |
851 | op->state->phase = PHASE_BF_EXCHANGE; | 851 | op->state->phase = PHASE_BF_EXCHANGE; |
852 | GNUNET_assert (NULL == op->state->my_elements); | ||
853 | op->state->my_elements | ||
854 | = GNUNET_CONTAINER_multihashmap_create (op->state->my_element_count, | ||
855 | GNUNET_YES); | ||
856 | GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->content->elements, | 852 | GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->content->elements, |
857 | &initialize_map_unfiltered, | 853 | &initialize_map_unfiltered, |
858 | op); | 854 | op); |
@@ -1034,6 +1030,9 @@ intersection_evaluate (struct Operation *op, | |||
1034 | /* we started the operation, thus we have to send the operation request */ | 1030 | /* we started the operation, thus we have to send the operation request */ |
1035 | op->state->phase = PHASE_INITIAL; | 1031 | op->state->phase = PHASE_INITIAL; |
1036 | op->state->my_element_count = op->spec->set->state->current_set_element_count; | 1032 | op->state->my_element_count = op->spec->set->state->current_set_element_count; |
1033 | op->state->my_elements | ||
1034 | = GNUNET_CONTAINER_multihashmap_create (op->state->my_element_count, | ||
1035 | GNUNET_YES); | ||
1037 | 1036 | ||
1038 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1039 | "Initiating intersection operation evaluation\n"); | 1038 | "Initiating intersection operation evaluation\n"); |
diff --git a/src/set/gnunet-service-set_intersection.h b/src/set/gnunet-service-set_intersection.h new file mode 100644 index 000000000..3bd255142 --- /dev/null +++ b/src/set/gnunet-service-set_intersection.h | |||
@@ -0,0 +1,79 @@ | |||
1 | |||
2 | /* | ||
3 | This file is part of GNUnet | ||
4 | Copyright (C) 2013-2017 GNUnet e.V. | ||
5 | |||
6 | GNUnet is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published | ||
8 | by the Free Software Foundation; either version 3, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | GNUnet is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNUnet; see the file COPYING. If not, write to the | ||
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | ||
20 | */ | ||
21 | /** | ||
22 | * @file set/gnunet-service-set_intersection.h | ||
23 | * @brief two-peer set operations | ||
24 | * @author Florian Dold | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_SET_INTERSECTION_H | ||
28 | #define GNUNET_SERVICE_SET_INTERSECTION_H | ||
29 | |||
30 | #include "gnunet-service-set.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Check an BF message from a remote peer. | ||
35 | * | ||
36 | * @param cls the intersection operation | ||
37 | * @param msg the header of the message | ||
38 | * @return #GNUNET_OK if @a msg is well-formed | ||
39 | */ | ||
40 | int | ||
41 | check_intersection_p2p_bf (void *cls, | ||
42 | const struct BFMessage *msg); | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Handle an BF message from a remote peer. | ||
47 | * | ||
48 | * @param cls the intersection operation | ||
49 | * @param msg the header of the message | ||
50 | */ | ||
51 | void | ||
52 | handle_intersection_p2p_bf (void *cls, | ||
53 | const struct BFMessage *msg); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Handle the initial `struct IntersectionElementInfoMessage` from a | ||
58 | * remote peer. | ||
59 | * | ||
60 | * @param cls the intersection operation | ||
61 | * @param mh the header of the message | ||
62 | */ | ||
63 | void | ||
64 | handle_intersection_p2p_element_info (void *cls, | ||
65 | const struct IntersectionElementInfoMessage *msg); | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Handle a done message from a remote peer | ||
70 | * | ||
71 | * @param cls the intersection operation | ||
72 | * @param mh the message | ||
73 | */ | ||
74 | void | ||
75 | handle_intersection_p2p_done (void *cls, | ||
76 | const struct IntersectionDoneMessage *idm); | ||
77 | |||
78 | |||
79 | #endif | ||
diff --git a/src/set/gnunet-service-set_union.h b/src/set/gnunet-service-set_union.h new file mode 100644 index 000000000..cbf60bcbc --- /dev/null +++ b/src/set/gnunet-service-set_union.h | |||
@@ -0,0 +1,239 @@ | |||
1 | |||
2 | /* | ||
3 | This file is part of GNUnet | ||
4 | Copyright (C) 2013-2017 GNUnet e.V. | ||
5 | |||
6 | GNUnet is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published | ||
8 | by the Free Software Foundation; either version 3, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | GNUnet is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNUnet; see the file COPYING. If not, write to the | ||
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | ||
20 | */ | ||
21 | /** | ||
22 | * @file set/gnunet-service-set_union.h | ||
23 | * @brief two-peer set operations | ||
24 | * @author Florian Dold | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_SET_UNION_H | ||
28 | #define GNUNET_SERVICE_SET_UNION_H | ||
29 | |||
30 | #include "gnunet-service-set.h" | ||
31 | #include "gnunet-service-set_protocol.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Handle a strata estimator from a remote peer | ||
36 | * | ||
37 | * @param cls the union operation | ||
38 | * @param msg the message | ||
39 | */ | ||
40 | int | ||
41 | check_union_p2p_strata_estimator (void *cls, | ||
42 | const struct StrataEstimatorMessage *msg); | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Handle a strata estimator from a remote peer | ||
47 | * | ||
48 | * @param cls the union operation | ||
49 | * @param msg the message | ||
50 | */ | ||
51 | void | ||
52 | handle_union_p2p_strata_estimator (void *cls, | ||
53 | const struct StrataEstimatorMessage *msg); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Check an IBF message from a remote peer. | ||
58 | * | ||
59 | * Reassemble the IBF from multiple pieces, and | ||
60 | * process the whole IBF once possible. | ||
61 | * | ||
62 | * @param cls the union operation | ||
63 | * @param msg the header of the message | ||
64 | * @return #GNUNET_OK if @a msg is well-formed | ||
65 | */ | ||
66 | int | ||
67 | check_union_p2p_ibf (void *cls, | ||
68 | const struct IBFMessage *msg); | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Handle an IBF message from a remote peer. | ||
73 | * | ||
74 | * Reassemble the IBF from multiple pieces, and | ||
75 | * process the whole IBF once possible. | ||
76 | * | ||
77 | * @param cls the union operation | ||
78 | * @param msg the header of the message | ||
79 | */ | ||
80 | void | ||
81 | handle_union_p2p_ibf (void *cls, | ||
82 | const struct IBFMessage *msg); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Check an element message from a remote peer. | ||
87 | * | ||
88 | * @param cls the union operation | ||
89 | * @param emsg the message | ||
90 | */ | ||
91 | int | ||
92 | check_union_p2p_elements (void *cls, | ||
93 | const struct GNUNET_SET_ElementMessage *emsg); | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Handle an element message from a remote peer. | ||
98 | * Sent by the other peer either because we decoded an IBF and placed a demand, | ||
99 | * or because the other peer switched to full set transmission. | ||
100 | * | ||
101 | * @param cls the union operation | ||
102 | * @param emsg the message | ||
103 | */ | ||
104 | void | ||
105 | handle_union_p2p_elements (void *cls, | ||
106 | const struct GNUNET_SET_ElementMessage *emsg); | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Check a full element message from a remote peer. | ||
111 | * | ||
112 | * @param cls the union operation | ||
113 | * @param emsg the message | ||
114 | */ | ||
115 | int | ||
116 | check_union_p2p_full_element (void *cls, | ||
117 | const struct GNUNET_SET_ElementMessage *emsg); | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Handle an element message from a remote peer. | ||
122 | * | ||
123 | * @param cls the union operation | ||
124 | * @param emsg the message | ||
125 | */ | ||
126 | void | ||
127 | handle_union_p2p_full_element (void *cls, | ||
128 | const struct GNUNET_SET_ElementMessage *emsg); | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Send offers (for GNUNET_Hash-es) in response | ||
133 | * to inquiries (for IBF_Key-s). | ||
134 | * | ||
135 | * @param cls the union operation | ||
136 | * @param msg the message | ||
137 | */ | ||
138 | int | ||
139 | check_union_p2p_inquiry (void *cls, | ||
140 | const struct InquiryMessage *msg); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Send offers (for GNUNET_Hash-es) in response | ||
145 | * to inquiries (for IBF_Key-s). | ||
146 | * | ||
147 | * @param cls the union operation | ||
148 | * @param msg the message | ||
149 | */ | ||
150 | void | ||
151 | handle_union_p2p_inquiry (void *cls, | ||
152 | const struct InquiryMessage *msg); | ||
153 | |||
154 | |||
155 | |||
156 | /** | ||
157 | * Handle a request for full set transmission. | ||
158 | * | ||
159 | * @parem cls closure, a set union operation | ||
160 | * @param mh the demand message | ||
161 | */ | ||
162 | void | ||
163 | handle_union_p2p_request_full (void *cls, | ||
164 | const struct GNUNET_MessageHeader *mh); | ||
165 | |||
166 | |||
167 | |||
168 | /** | ||
169 | * Handle a "full done" message. | ||
170 | * | ||
171 | * @parem cls closure, a set union operation | ||
172 | * @param mh the demand message | ||
173 | */ | ||
174 | void | ||
175 | handle_union_p2p_full_done (void *cls, | ||
176 | const struct GNUNET_MessageHeader *mh); | ||
177 | |||
178 | |||
179 | /** | ||
180 | * Check a demand by the other peer for elements based on a list | ||
181 | * of `struct GNUNET_HashCode`s. | ||
182 | * | ||
183 | * @parem cls closure, a set union operation | ||
184 | * @param mh the demand message | ||
185 | * @return #GNUNET_OK if @a mh is well-formed | ||
186 | */ | ||
187 | int | ||
188 | check_union_p2p_demand (void *cls, | ||
189 | const struct GNUNET_MessageHeader *mh); | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Handle a demand by the other peer for elements based on a list | ||
194 | * of `struct GNUNET_HashCode`s. | ||
195 | * | ||
196 | * @parem cls closure, a set union operation | ||
197 | * @param mh the demand message | ||
198 | */ | ||
199 | void | ||
200 | handle_union_p2p_demand (void *cls, | ||
201 | const struct GNUNET_MessageHeader *mh); | ||
202 | |||
203 | |||
204 | /** | ||
205 | * Check offer (of `struct GNUNET_HashCode`s). | ||
206 | * | ||
207 | * @param cls the union operation | ||
208 | * @param mh the message | ||
209 | * @return #GNUNET_OK if @a mh is well-formed | ||
210 | */ | ||
211 | int | ||
212 | check_union_p2p_offer (void *cls, | ||
213 | const struct GNUNET_MessageHeader *mh); | ||
214 | |||
215 | |||
216 | /** | ||
217 | * Handle offers (of `struct GNUNET_HashCode`s) and | ||
218 | * respond with demands (of `struct GNUNET_HashCode`s). | ||
219 | * | ||
220 | * @param cls the union operation | ||
221 | * @param mh the message | ||
222 | */ | ||
223 | void | ||
224 | handle_union_p2p_offer (void *cls, | ||
225 | const struct GNUNET_MessageHeader *mh); | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Handle a done message from a remote peer | ||
230 | * | ||
231 | * @param cls the union operation | ||
232 | * @param mh the message | ||
233 | */ | ||
234 | void | ||
235 | handle_union_p2p_done (void *cls, | ||
236 | const struct GNUNET_MessageHeader *mh); | ||
237 | |||
238 | |||
239 | #endif | ||