diff options
Diffstat (limited to 'src/peerstore')
-rw-r--r-- | src/peerstore/peerstore_api.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index b1f4695ec..b08de8229 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013-2014 GNUnet e.V. | 3 | Copyright (C) 2013-2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -46,11 +46,6 @@ struct GNUNET_PEERSTORE_Handle | |||
46 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 46 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Connection to the service. | ||
50 | */ | ||
51 | struct GNUNET_CLIENT_Connection *client; | ||
52 | |||
53 | /** | ||
54 | * Message queue | 49 | * Message queue |
55 | */ | 50 | */ |
56 | struct GNUNET_MQ_Handle *mq; | 51 | struct GNUNET_MQ_Handle *mq; |
@@ -385,11 +380,6 @@ do_disconnect (struct GNUNET_PEERSTORE_Handle *h) | |||
385 | GNUNET_MQ_destroy (h->mq); | 380 | GNUNET_MQ_destroy (h->mq); |
386 | h->mq = NULL; | 381 | h->mq = NULL; |
387 | } | 382 | } |
388 | if (NULL != h->client) | ||
389 | { | ||
390 | GNUNET_CLIENT_disconnect (h->client); | ||
391 | h->client = NULL; | ||
392 | } | ||
393 | GNUNET_free (h); | 383 | GNUNET_free (h); |
394 | } | 384 | } |
395 | 385 | ||
@@ -406,16 +396,14 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
406 | struct GNUNET_PEERSTORE_Handle *h; | 396 | struct GNUNET_PEERSTORE_Handle *h; |
407 | 397 | ||
408 | h = GNUNET_new (struct GNUNET_PEERSTORE_Handle); | 398 | h = GNUNET_new (struct GNUNET_PEERSTORE_Handle); |
409 | 399 | h->cfg = cfg; | |
410 | h->client = GNUNET_CLIENT_connect ("peerstore", cfg); | 400 | h->disconnecting = GNUNET_NO; |
411 | if (NULL == h->client) | 401 | reconnect (h); |
402 | if (NULL == h->mq) | ||
412 | { | 403 | { |
413 | GNUNET_free (h); | 404 | GNUNET_free (h); |
414 | return NULL; | 405 | return NULL; |
415 | } | 406 | } |
416 | h->cfg = cfg; | ||
417 | h->disconnecting = GNUNET_NO; | ||
418 | reconnect (h); | ||
419 | return h; | 407 | return h; |
420 | } | 408 | } |
421 | 409 | ||
@@ -819,6 +807,7 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h) | |||
819 | void *icb_cls; | 807 | void *icb_cls; |
820 | struct GNUNET_PEERSTORE_StoreContext *sc; | 808 | struct GNUNET_PEERSTORE_StoreContext *sc; |
821 | struct GNUNET_MQ_Envelope *ev; | 809 | struct GNUNET_MQ_Envelope *ev; |
810 | struct GNUNET_CLIENT_Connection *client; | ||
822 | 811 | ||
823 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 812 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
824 | "Reconnecting...\n"); | 813 | "Reconnecting...\n"); |
@@ -841,15 +830,11 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h) | |||
841 | GNUNET_MQ_destroy (h->mq); | 830 | GNUNET_MQ_destroy (h->mq); |
842 | h->mq = NULL; | 831 | h->mq = NULL; |
843 | } | 832 | } |
844 | if (NULL != h->client) | 833 | client = GNUNET_CLIENT_connect ("peerstore", |
845 | { | 834 | h->cfg); |
846 | GNUNET_CLIENT_disconnect (h->client); | 835 | if (NULL == client) |
847 | h->client = NULL; | 836 | return; |
848 | } | 837 | h->mq = GNUNET_MQ_queue_for_connection_client (client, |
849 | h->client = GNUNET_CLIENT_connect ("peerstore", | ||
850 | h->cfg); | ||
851 | GNUNET_assert (NULL != h->client); | ||
852 | h->mq = GNUNET_MQ_queue_for_connection_client (h->client, | ||
853 | mq_handlers, | 838 | mq_handlers, |
854 | &handle_client_error, h); | 839 | &handle_client_error, h); |
855 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 840 | LOG (GNUNET_ERROR_TYPE_DEBUG, |