summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-04-11 13:56:22 +0000
committerChristian Grothoff <christian@grothoff.org>2013-04-11 13:56:22 +0000
commit4673d14115b5ae163c2dde205a3611e7f937404d (patch)
tree89bc9290433690bada9685df7a380eff04297e7d
parent91a834246d29ad61784de62f6a56551138394ccc (diff)
-consensus fix
-rw-r--r--src/consensus/consensus_api.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c
index fd61d3712..635a610ca 100644
--- a/src/consensus/consensus_api.c
+++ b/src/consensus/consensus_api.c
@@ -138,13 +138,9 @@ struct GNUNET_CONSENSUS_Handle
unsigned int conclude_min_size;
struct QueuedMessage *messages_head;
+
struct QueuedMessage *messages_tail;
- /**
- * GNUNET_YES when currently in a section where destroy may not be
- * called.
- */
- int may_not_destroy;
};
@@ -265,17 +261,16 @@ handle_new_element (struct GNUNET_CONSENSUS_Handle *consensus,
*/
static void
handle_conclude_done (struct GNUNET_CONSENSUS_Handle *consensus,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
- GNUNET_assert (NULL != consensus->conclude_cb);
- consensus->may_not_destroy = GNUNET_YES;
- consensus->conclude_cb (consensus->conclude_cls);
- consensus->may_not_destroy = GNUNET_NO;
+ GNUNET_CONSENSUS_ConcludeCallback cc;
+
+ GNUNET_assert (NULL != (cc = consensus->conclude_cb));
consensus->conclude_cb = NULL;
+ cc (consensus->conclude_cls);
}
-
/**
* Type of a function to call when we receive a message
* from the service.
@@ -290,7 +285,7 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
LOG (GNUNET_ERROR_TYPE_DEBUG, "received message from consensus service\n");
- if (msg == NULL)
+ if (NULL == msg)
{
/* Error, timeout, death */
LOG (GNUNET_ERROR_TYPE_ERROR, "error receiving\n");
@@ -299,7 +294,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
consensus->new_element_cb (consensus->new_element_cls, NULL);
return;
}
-
+ GNUNET_CLIENT_receive (consensus->client, &message_handler, consensus,
+ GNUNET_TIME_UNIT_FOREVER_REL);
switch (ntohs (msg->type))
{
case GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT:
@@ -311,8 +307,6 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
default:
GNUNET_break (0);
}
- GNUNET_CLIENT_receive (consensus->client, &message_handler, consensus,
- GNUNET_TIME_UNIT_FOREVER_REL);
}
/**
@@ -509,11 +503,6 @@ GNUNET_CONSENSUS_conclude (struct GNUNET_CONSENSUS_Handle *consensus,
void
GNUNET_CONSENSUS_destroy (struct GNUNET_CONSENSUS_Handle *consensus)
{
- if (GNUNET_YES == consensus->may_not_destroy)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "destroy may not be called right now\n");
- GNUNET_assert (0);
- }
if (consensus->client != NULL)
{
GNUNET_CLIENT_disconnect (consensus->client);