From: Christian Grothoff Date: Fri, 14 May 2010 15:11:10 +0000 (+0000) Subject: fixes X-Git-Tag: initial-import-from-subversion-38251~21708 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=db482ed2af464d52e84ee20abe369ce9296afc72;p=oweals%2Fgnunet.git fixes --- diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 24f058556..7bdd3b38b 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -243,19 +243,32 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, struct GNUNET_DATASTORE_QueueEntry *qe; if (h->client != NULL) - GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); + { + GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); + h->client = NULL; + } if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - h->reconnect_task); - h->client = NULL; + { + GNUNET_SCHEDULER_cancel (h->sched, + h->reconnect_task); + h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; + } while (NULL != (qe = h->queue_head)) { - GNUNET_CONTAINER_DLL_remove (h->queue_head, - h->queue_tail, - qe); if (NULL != qe->response_proc) - qe->response_proc (qe, NULL); - GNUNET_free (qe); + { + qe->response_proc (qe, NULL); + } + else + { + GNUNET_CONTAINER_DLL_remove (h->queue_head, + h->queue_tail, + qe); + if (qe->task != GNUNET_SCHEDULER_NO_TASK) + GNUNET_SCHEDULER_cancel (h->sched, + qe->task); + GNUNET_free (qe); + } } if (GNUNET_YES == drop) { @@ -435,6 +448,8 @@ try_reconnect (void *cls, static void do_disconnect (struct GNUNET_DATASTORE_Handle *h) { + if (h->client == NULL) + return; GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); h->client = NULL; h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, @@ -573,9 +588,17 @@ process_status_message (void *cls, GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, qe); + if (qe->task != GNUNET_SCHEDULER_NO_TASK) + { + GNUNET_SCHEDULER_cancel (h->sched, + qe->task); + qe->task = GNUNET_SCHEDULER_NO_TASK; + } GNUNET_free (qe); if (msg == NULL) - { + { + if (NULL == h->client) + return; /* forced disconnect */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to receive response from database.\n")); do_disconnect (h);