diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
commit | 8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch) | |
tree | 0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/gnunet-service-peerstore.c | |
parent | 6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff) | |
download | gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.tar.gz gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.zip |
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/gnunet-service-peerstore.c')
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index 8200c2366..92d020799 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -260,15 +260,23 @@ record_iterator (void *cls, | |||
260 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cls_record->client), | 260 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cls_record->client), |
261 | env); | 261 | env); |
262 | if (NULL == emsg) | 262 | if (NULL == emsg) |
263 | { | ||
263 | GNUNET_SERVICE_client_continue (cls_record->client); | 264 | GNUNET_SERVICE_client_continue (cls_record->client); |
265 | } | ||
264 | else | 266 | else |
267 | { | ||
268 | GNUNET_break (0); | ||
269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
270 | "Failed to iterate: %s\n", | ||
271 | emsg); | ||
265 | GNUNET_SERVICE_client_drop (cls_record->client); | 272 | GNUNET_SERVICE_client_drop (cls_record->client); |
273 | } | ||
266 | PEERSTORE_destroy_record (cls_record); | 274 | PEERSTORE_destroy_record (cls_record); |
267 | return; | 275 | return; |
268 | } | 276 | } |
269 | 277 | ||
270 | env = PEERSTORE_create_record_mq_envelope (record->sub_system, | 278 | env = PEERSTORE_create_record_mq_envelope (record->sub_system, |
271 | record->peer, | 279 | &record->peer, |
272 | record->key, | 280 | record->key, |
273 | record->value, | 281 | record->value, |
274 | record->value_size, | 282 | record->value_size, |
@@ -301,7 +309,7 @@ watch_notifier_it (void *cls, | |||
301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
302 | "Found a watcher to update.\n"); | 310 | "Found a watcher to update.\n"); |
303 | env = PEERSTORE_create_record_mq_envelope (record->sub_system, | 311 | env = PEERSTORE_create_record_mq_envelope (record->sub_system, |
304 | record->peer, | 312 | &record->peer, |
305 | record->key, | 313 | record->key, |
306 | record->value, | 314 | record->value, |
307 | record->value_size, | 315 | record->value_size, |
@@ -325,7 +333,7 @@ watch_notifier (struct GNUNET_PEERSTORE_Record *record) | |||
325 | struct GNUNET_HashCode keyhash; | 333 | struct GNUNET_HashCode keyhash; |
326 | 334 | ||
327 | PEERSTORE_hash_key (record->sub_system, | 335 | PEERSTORE_hash_key (record->sub_system, |
328 | record->peer, | 336 | &record->peer, |
329 | record->key, | 337 | record->key, |
330 | &keyhash); | 338 | &keyhash); |
331 | GNUNET_CONTAINER_multihashmap_get_multiple (watchers, | 339 | GNUNET_CONTAINER_multihashmap_get_multiple (watchers, |
@@ -434,17 +442,18 @@ handle_iterate (void *cls, | |||
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 442 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
435 | "Iterate request: ss `%s', peer `%s', key `%s'\n", | 443 | "Iterate request: ss `%s', peer `%s', key `%s'\n", |
436 | record->sub_system, | 444 | record->sub_system, |
437 | (NULL == record->peer) ? "NULL" : GNUNET_i2s (record->peer), | 445 | GNUNET_i2s (&record->peer), |
438 | (NULL == record->key) ? "NULL" : record->key); | 446 | (NULL == record->key) ? "NULL" : record->key); |
439 | record->client = client; | 447 | record->client = client; |
440 | if (GNUNET_OK != | 448 | if (GNUNET_OK != |
441 | db->iterate_records (db->cls, | 449 | db->iterate_records (db->cls, |
442 | record->sub_system, | 450 | record->sub_system, |
443 | record->peer, | 451 | (ntohs (srm->peer_set)) ? &record->peer : NULL, |
444 | record->key, | 452 | record->key, |
445 | &record_iterator, | 453 | &record_iterator, |
446 | record)) | 454 | record)) |
447 | { | 455 | { |
456 | GNUNET_break (0); | ||
448 | GNUNET_SERVICE_client_drop (client); | 457 | GNUNET_SERVICE_client_drop (client); |
449 | PEERSTORE_destroy_record (record); | 458 | PEERSTORE_destroy_record (record); |
450 | } | 459 | } |
@@ -470,6 +479,7 @@ store_record_continuation (void *cls, | |||
470 | } | 479 | } |
471 | else | 480 | else |
472 | { | 481 | { |
482 | GNUNET_break (0); | ||
473 | GNUNET_SERVICE_client_drop (record->client); | 483 | GNUNET_SERVICE_client_drop (record->client); |
474 | } | 484 | } |
475 | PEERSTORE_destroy_record (record); | 485 | PEERSTORE_destroy_record (record); |
@@ -496,7 +506,6 @@ check_store (void *cls, | |||
496 | return GNUNET_SYSERR; | 506 | return GNUNET_SYSERR; |
497 | } | 507 | } |
498 | if ( (NULL == record->sub_system) || | 508 | if ( (NULL == record->sub_system) || |
499 | (NULL == record->peer) || | ||
500 | (NULL == record->key) ) | 509 | (NULL == record->key) ) |
501 | { | 510 | { |
502 | GNUNET_break (0); | 511 | GNUNET_break (0); |
@@ -525,22 +534,23 @@ handle_store (void *cls, | |||
525 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 534 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
526 | "Received a store request. Sub system `%s' Peer `%s Key `%s' Options: %u.\n", | 535 | "Received a store request. Sub system `%s' Peer `%s Key `%s' Options: %u.\n", |
527 | record->sub_system, | 536 | record->sub_system, |
528 | GNUNET_i2s (record->peer), | 537 | GNUNET_i2s (&record->peer), |
529 | record->key, | 538 | record->key, |
530 | (uint32_t) ntohl (srm->options)); | 539 | (uint32_t) ntohl (srm->options)); |
531 | record->client = client; | 540 | record->client = client; |
532 | if (GNUNET_OK != | 541 | if (GNUNET_OK != |
533 | db->store_record (db->cls, | 542 | db->store_record (db->cls, |
534 | record->sub_system, | 543 | record->sub_system, |
535 | record->peer, | 544 | &record->peer, |
536 | record->key, | 545 | record->key, |
537 | record->value, | 546 | record->value, |
538 | record->value_size, | 547 | record->value_size, |
539 | *record->expiry, | 548 | record->expiry, |
540 | ntohl (srm->options), | 549 | ntohl (srm->options), |
541 | &store_record_continuation, | 550 | &store_record_continuation, |
542 | record)) | 551 | record)) |
543 | { | 552 | { |
553 | GNUNET_break (0); | ||
544 | PEERSTORE_destroy_record (record); | 554 | PEERSTORE_destroy_record (record); |
545 | GNUNET_SERVICE_client_drop (client); | 555 | GNUNET_SERVICE_client_drop (client); |
546 | return; | 556 | return; |