aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/peerstore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
commit8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch)
tree0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/peerstore_api.c
parent6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff)
downloadgnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.tar.gz
gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.zip
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r--src/peerstore/peerstore_api.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index c9fcd17ab..df182fe10 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -286,6 +286,10 @@ store_request_sent (void *cls)
286/******************* CONNECTION FUNCTIONS *********************/ 286/******************* CONNECTION FUNCTIONS *********************/
287/******************************************************************************/ 287/******************************************************************************/
288 288
289
290/**
291 * Function called when we had trouble talking to the service.
292 */
289static void 293static void
290handle_client_error (void *cls, 294handle_client_error (void *cls,
291 enum GNUNET_MQ_Error error) 295 enum GNUNET_MQ_Error error)
@@ -293,7 +297,7 @@ handle_client_error (void *cls,
293 struct GNUNET_PEERSTORE_Handle *h = cls; 297 struct GNUNET_PEERSTORE_Handle *h = cls;
294 298
295 LOG (GNUNET_ERROR_TYPE_ERROR, 299 LOG (GNUNET_ERROR_TYPE_ERROR,
296 _("Received an error notification from MQ of type: %d\n"), 300 "Received an error notification from MQ of type: %d\n",
297 error); 301 error);
298 reconnect (h); 302 reconnect (h);
299} 303}
@@ -341,7 +345,9 @@ iterate_timeout (void *cls)
341 callback_cls = ic->callback_cls; 345 callback_cls = ic->callback_cls;
342 GNUNET_PEERSTORE_iterate_cancel (ic); 346 GNUNET_PEERSTORE_iterate_cancel (ic);
343 if (NULL != callback) 347 if (NULL != callback)
344 callback (callback_cls, NULL, _("timeout")); 348 callback (callback_cls,
349 NULL,
350 _("timeout"));
345} 351}
346 352
347 353
@@ -510,7 +516,7 @@ GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
510 "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n", 516 "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
511 size, sub_system, GNUNET_i2s (peer), key); 517 size, sub_system, GNUNET_i2s (peer), key);
512 ev = PEERSTORE_create_record_mq_envelope (sub_system, peer, key, value, size, 518 ev = PEERSTORE_create_record_mq_envelope (sub_system, peer, key, value, size,
513 &expiry, options, 519 expiry, options,
514 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE); 520 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
515 sc = GNUNET_new (struct GNUNET_PEERSTORE_StoreContext); 521 sc = GNUNET_new (struct GNUNET_PEERSTORE_StoreContext);
516 522
@@ -684,8 +690,12 @@ GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h,
684 struct GNUNET_MQ_Envelope *ev; 690 struct GNUNET_MQ_Envelope *ev;
685 struct GNUNET_PEERSTORE_IterateContext *ic; 691 struct GNUNET_PEERSTORE_IterateContext *ic;
686 692
687 ev = PEERSTORE_create_record_mq_envelope (sub_system, peer, key, NULL, 0, 693 ev = PEERSTORE_create_record_mq_envelope (sub_system,
694 peer,
695 key,
688 NULL, 0, 696 NULL, 0,
697 GNUNET_TIME_UNIT_FOREVER_ABS,
698 0,
689 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE); 699 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
690 ic = GNUNET_new (struct GNUNET_PEERSTORE_IterateContext); 700 ic = GNUNET_new (struct GNUNET_PEERSTORE_IterateContext);
691 701
@@ -756,7 +766,7 @@ handle_watch_record (void *cls,
756 return; 766 return;
757 } 767 }
758 PEERSTORE_hash_key (record->sub_system, 768 PEERSTORE_hash_key (record->sub_system,
759 record->peer, 769 &record->peer,
760 record->key, 770 record->key,
761 &keyhash); 771 &keyhash);
762 // FIXME: what if there are multiple watches for the same key? 772 // FIXME: what if there are multiple watches for the same key?
@@ -848,9 +858,12 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
848 &ic->peer, 858 &ic->peer,
849 ic->key, 859 ic->key,
850 NULL, 0, 860 NULL, 0,
851 NULL, 0, 861 GNUNET_TIME_UNIT_FOREVER_ABS,
862 0,
852 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE); 863 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
853 GNUNET_MQ_send (h->mq, ev); 864 GNUNET_MQ_send (h->mq, ev);
865 if (NULL != ic->timeout_task)
866 GNUNET_SCHEDULER_cancel (ic->timeout_task);
854 ic->timeout_task 867 ic->timeout_task
855 = GNUNET_SCHEDULER_add_delayed (ic->timeout, 868 = GNUNET_SCHEDULER_add_delayed (ic->timeout,
856 &iterate_timeout, 869 &iterate_timeout,
@@ -863,7 +876,7 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
863 sc->key, 876 sc->key,
864 sc->value, 877 sc->value,
865 sc->size, 878 sc->size,
866 &sc->expiry, 879 sc->expiry,
867 sc->options, 880 sc->options,
868 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE); 881 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
869 GNUNET_MQ_notify_sent (ev, 882 GNUNET_MQ_notify_sent (ev,