diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-19 18:50:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-19 18:50:00 +0000 |
commit | 2042d867f71e3cb1d7ade6b3d474ce0c1f5f87bd (patch) | |
tree | 58be8b2e7321a91015df8ab3281a9f89a26cec1f /src/peerstore | |
parent | d8d3021ad9af2abe551fd6cd0fe2529a99d3683c (diff) |
redefine GNUNET_MQ_queue_for_connection_client to capture client handle
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 b1f4695ec0..b08de82297 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2013-2014 GNUnet e.V. + Copyright (C) 2013-2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -46,11 +46,6 @@ struct GNUNET_PEERSTORE_Handle const struct GNUNET_CONFIGURATION_Handle *cfg; /** - * Connection to the service. - */ - struct GNUNET_CLIENT_Connection *client; - - /** * Message queue */ struct GNUNET_MQ_Handle *mq; @@ -385,11 +380,6 @@ do_disconnect (struct GNUNET_PEERSTORE_Handle *h) GNUNET_MQ_destroy (h->mq); h->mq = NULL; } - if (NULL != h->client) - { - GNUNET_CLIENT_disconnect (h->client); - h->client = NULL; - } GNUNET_free (h); } @@ -406,16 +396,14 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) struct GNUNET_PEERSTORE_Handle *h; h = GNUNET_new (struct GNUNET_PEERSTORE_Handle); - - h->client = GNUNET_CLIENT_connect ("peerstore", cfg); - if (NULL == h->client) + h->cfg = cfg; + h->disconnecting = GNUNET_NO; + reconnect (h); + if (NULL == h->mq) { GNUNET_free (h); return NULL; } - h->cfg = cfg; - h->disconnecting = GNUNET_NO; - reconnect (h); return h; } @@ -819,6 +807,7 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h) void *icb_cls; struct GNUNET_PEERSTORE_StoreContext *sc; struct GNUNET_MQ_Envelope *ev; + struct GNUNET_CLIENT_Connection *client; LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n"); @@ -841,15 +830,11 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h) GNUNET_MQ_destroy (h->mq); h->mq = NULL; } - if (NULL != h->client) - { - GNUNET_CLIENT_disconnect (h->client); - h->client = NULL; - } - h->client = GNUNET_CLIENT_connect ("peerstore", - h->cfg); - GNUNET_assert (NULL != h->client); - h->mq = GNUNET_MQ_queue_for_connection_client (h->client, + client = GNUNET_CLIENT_connect ("peerstore", + h->cfg); + if (NULL == client) + return; + h->mq = GNUNET_MQ_queue_for_connection_client (client, mq_handlers, &handle_client_error, h); LOG (GNUNET_ERROR_TYPE_DEBUG, |