aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-05-16 17:23:47 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-05-16 17:23:47 +0000
commitd78b7d8a3f6cdaee244557667350da443ca76db5 (patch)
tree58f8a036377207768768ccbc2866a865865edfbb /src/peerstore
parentd2f4cf2b57f6db7d788173ead9b8826deb3338f2 (diff)
downloadgnunet-d78b7d8a3f6cdaee244557667350da443ca76db5.tar.gz
gnunet-d78b7d8a3f6cdaee244557667350da443ca76db5.zip
minor fixes
Diffstat (limited to 'src/peerstore')
-rw-r--r--src/peerstore/peerstore_api.c17
-rw-r--r--src/peerstore/peerstore_common.c1
-rw-r--r--src/peerstore/test_peerstore_api.c1
3 files changed, 19 insertions, 0 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index 5a2455014..edf506f10 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -148,6 +148,21 @@ handle_client_error (void *cls, enum GNUNET_MQ_Error error)
148} 148}
149 149
150/** 150/**
151 * Should be called only after destroying MQ and connection
152 */
153static void
154cleanup_handle(struct GNUNET_PEERSTORE_Handle *h)
155{
156 struct GNUNET_PEERSTORE_StoreContext *sc;
157
158 while (NULL != (sc = h->store_head))
159 {
160 GNUNET_CONTAINER_DLL_remove(h->store_head, h->store_tail, sc);
161 GNUNET_free(sc);
162 }
163}
164
165/**
151 * Close the existing connection to PEERSTORE and reconnect. 166 * Close the existing connection to PEERSTORE and reconnect.
152 * 167 *
153 * @param h handle to the service 168 * @param h handle to the service
@@ -167,6 +182,7 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
167 GNUNET_CLIENT_disconnect (h->client); 182 GNUNET_CLIENT_disconnect (h->client);
168 h->client = NULL; 183 h->client = NULL;
169 } 184 }
185 cleanup_handle(h);
170 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg); 186 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
171 h->mq = GNUNET_MQ_queue_for_connection_client(h->client, 187 h->mq = GNUNET_MQ_queue_for_connection_client(h->client,
172 mq_handlers, 188 mq_handlers,
@@ -225,6 +241,7 @@ GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
225 GNUNET_CLIENT_disconnect (h->client); 241 GNUNET_CLIENT_disconnect (h->client);
226 h->client = NULL; 242 h->client = NULL;
227 } 243 }
244 cleanup_handle(h);
228 GNUNET_free(h); 245 GNUNET_free(h);
229 LOG(GNUNET_ERROR_TYPE_DEBUG, "Disconnected, BYE!\n"); 246 LOG(GNUNET_ERROR_TYPE_DEBUG, "Disconnected, BYE!\n");
230} 247}
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c
index 6c91d9802..2cb9d0077 100644
--- a/src/peerstore/peerstore_common.c
+++ b/src/peerstore/peerstore_common.c
@@ -113,6 +113,7 @@ PEERSTORE_create_record_mq_envelope(const char *sub_system,
113 size_t msg_size; 113 size_t msg_size;
114 void *dummy; 114 void *dummy;
115 115
116 GNUNET_assert(NULL != sub_system);
116 ss_size = strlen(sub_system) + 1; 117 ss_size = strlen(sub_system) + 1;
117 if(NULL == key) 118 if(NULL == key)
118 key_size = 0; 119 key_size = 0;
diff --git a/src/peerstore/test_peerstore_api.c b/src/peerstore/test_peerstore_api.c
index 74f3e70db..d17c6fff0 100644
--- a/src/peerstore/test_peerstore_api.c
+++ b/src/peerstore/test_peerstore_api.c
@@ -36,6 +36,7 @@ void store_cont(void *cls, int success)
36 ok = 0; 36 ok = 0;
37 else 37 else
38 ok = 1; 38 ok = 1;
39 printf("Success: %d\n", success);
39 GNUNET_PEERSTORE_disconnect(h); 40 GNUNET_PEERSTORE_disconnect(h);
40} 41}
41 42