diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-05-16 17:23:47 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-05-16 17:23:47 +0000 |
commit | d78b7d8a3f6cdaee244557667350da443ca76db5 (patch) | |
tree | 58f8a036377207768768ccbc2866a865865edfbb /src/peerstore/peerstore_api.c | |
parent | d2f4cf2b57f6db7d788173ead9b8826deb3338f2 (diff) | |
download | gnunet-d78b7d8a3f6cdaee244557667350da443ca76db5.tar.gz gnunet-d78b7d8a3f6cdaee244557667350da443ca76db5.zip |
minor fixes
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r-- | src/peerstore/peerstore_api.c | 17 |
1 files changed, 17 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 | */ | ||
153 | static void | ||
154 | cleanup_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 | } |