X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fidentity%2Fidentity_api.c;h=a31086f5db88498b8288ea4f3cd347e7edfc3c0f;hb=8aa21ee7de6c4a6cb9c1e132ab4218d3d10e0e30;hp=931deb509f707bb2f6a86e260bfabd9bb2ceebd3;hpb=9351b1e9bdf2b067b6db06562c26ba658cff42b8;p=oweals%2Fgnunet.git diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 931deb509..a31086f5d 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2013 Christian Grothoff (and other contributing authors) + Copyright (C) 2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public Liceidentity as published @@ -87,19 +87,19 @@ struct GNUNET_IDENTITY_Operation const struct GNUNET_MessageHeader *msg; /** - * Continuation to invoke with the result of the transmission; 'cb' + * Continuation to invoke with the result of the transmission; @e cb * will be NULL in this case. */ GNUNET_IDENTITY_Continuation cont; /** * Continuation to invoke with the result of the transmission for - * 'get' operations ('cont' will be NULL in this case). + * 'get' operations (@e cont will be NULL in this case). */ GNUNET_IDENTITY_Callback cb; /** - * Closure for 'cont' or 'cb'. + * Closure for @e cont or @e cb. */ void *cls; @@ -155,7 +155,7 @@ struct GNUNET_IDENTITY_Handle /** * Task doing exponential back-off trying to reconnect. */ - GNUNET_SCHEDULER_TaskIdentifier reconnect_task; + struct GNUNET_SCHEDULER_Task * reconnect_task; /** * Time for next connect retry. @@ -210,7 +210,7 @@ reconnect (void *cls, static void reschedule_connect (struct GNUNET_IDENTITY_Handle *h) { - GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); + GNUNET_assert (h->reconnect_task == NULL); if (NULL != h->th) { @@ -418,6 +418,14 @@ message_handler (void *cls, return; } op = h->op_head; + if (NULL == op) + { + GNUNET_break (0); + reschedule_connect (h); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received SET_DEFAULT message from identity service\n"); GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); @@ -534,7 +542,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_IDENTITY_Operation *op; struct GNUNET_MessageHeader msg; - h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; + h->reconnect_task = NULL; LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); GNUNET_assert (NULL == h->client); @@ -889,6 +897,8 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) (NULL == h->client) ) { /* request not active, can simply remove */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client aborted non-head operation, simply removing it\n"); GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); @@ -898,6 +908,8 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) if (NULL != h->th) { /* request active but not yet with service, can still abort */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client aborted head operation prior to transmission, aborting it\n"); GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); h->th = NULL; GNUNET_CONTAINER_DLL_remove (h->op_head, @@ -908,6 +920,8 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) return; } /* request active with service, simply ensure continuations are not called */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client aborted active request, NULLing continuation\n"); op->cont = NULL; op->cb = NULL; } @@ -952,17 +966,10 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) struct GNUNET_IDENTITY_Operation *op; GNUNET_assert (NULL != h); - while (NULL != (op = h->op_head)) - { - GNUNET_CONTAINER_DLL_remove (h->op_head, - h->op_tail, - op); - GNUNET_free (op); - } - if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) + if (h->reconnect_task != NULL) { GNUNET_SCHEDULER_cancel (h->reconnect_task); - h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; + h->reconnect_task = NULL; } if (NULL != h->th) { @@ -977,6 +984,14 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) GNUNET_CONTAINER_multihashmap_destroy (h->egos); h->egos = NULL; } + while (NULL != (op = h->op_head)) + { + GNUNET_break (NULL == op->cont); + GNUNET_CONTAINER_DLL_remove (h->op_head, + h->op_tail, + op); + GNUNET_free (op); + } if (NULL != h->client) { GNUNET_CLIENT_disconnect (h->client);