aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-04-03 13:31:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-04-03 13:31:15 +0000
commit89fbfa0dc3f6e4f301e892c76937d0a09667f2b4 (patch)
tree526287cd43aa8e9046a4a588fbc53108f779d348 /src
parent3a2c5bed831339afdb4166644adfd466af1f14ef (diff)
downloadgnunet-89fbfa0dc3f6e4f301e892c76937d0a09667f2b4.tar.gz
gnunet-89fbfa0dc3f6e4f301e892c76937d0a09667f2b4.zip
- fix 2853
Diffstat (limited to 'src')
-rw-r--r--src/arm/arm_api.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index 754398fc5..f221dac7b 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -199,27 +199,6 @@ reconnect_arm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
199} 199}
200 200
201 201
202static void
203clear_pending_messages (struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus result)
204{
205 struct ARMControlMessage *cm;
206
207 LOG (GNUNET_ERROR_TYPE_DEBUG,
208 "Clearing pending messages\n");
209
210 while (NULL != (cm = h->control_pending_head))
211 {
212 GNUNET_CONTAINER_DLL_remove (h->control_pending_head,
213 h->control_pending_tail, cm);
214 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cm->timeout_task_id);
215 GNUNET_SCHEDULER_cancel (cm->timeout_task_id);
216 if (NULL != cm->result_cont)
217 cm->result_cont (cm->cont_cls, cm->h, result, NULL, 0);
218 GNUNET_free_non_null (cm->msg);
219 GNUNET_free (cm);
220 }
221}
222
223/** 202/**
224 * Close down any existing connection to the ARM service and 203 * Close down any existing connection to the ARM service and
225 * try re-establishing it later. 204 * try re-establishing it later.
@@ -444,13 +423,32 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
444void 423void
445GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h) 424GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h)
446{ 425{
426 struct ARMControlMessage *cm;
427
447 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n"); 428 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n");
448 if (NULL != h->cth) 429 if (NULL != h->cth)
449 { 430 {
450 GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); 431 GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth);
451 h->cth = NULL; 432 h->cth = NULL;
452 } 433 }
453 clear_pending_messages (h, GNUNET_ARM_REQUEST_DISCONNECTED); 434 while ((NULL != (cm = h->control_pending_head))
435 || (NULL != (cm = h->control_sent_head)) )
436 {
437 if (NULL != h->control_pending_head)
438 GNUNET_CONTAINER_DLL_remove (h->control_pending_head,
439 h->control_pending_tail, cm);
440 else
441 GNUNET_CONTAINER_DLL_remove (h->control_sent_head,
442 h->control_sent_tail, cm);
443 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cm->timeout_task_id);
444 GNUNET_SCHEDULER_cancel (cm->timeout_task_id);
445 if (NULL != cm->result_cont)
446 cm->result_cont (cm->cont_cls, cm->h, GNUNET_ARM_REQUEST_DISCONNECTED,
447 NULL, 0);
448 /* FIXME: What about list callback? */
449 GNUNET_free_non_null (cm->msg);
450 GNUNET_free (cm);
451 }
454 if (NULL != h->client) 452 if (NULL != h->client)
455 { 453 {
456 GNUNET_CLIENT_disconnect (h->client); 454 GNUNET_CLIENT_disconnect (h->client);