From: Christian Grothoff Date: Sat, 16 Nov 2013 17:41:13 +0000 (+0000) Subject: -remove GNUNET_MQ_impl_send_commit, make it part of send_continue, to ensure calling... X-Git-Tag: initial-import-from-subversion-38251~6056 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ba0bf2a585c2b59890d8f67074b74725430e86e8;p=oweals%2Fgnunet.git -remove GNUNET_MQ_impl_send_commit, make it part of send_continue, to ensure calling the continuation _last_ --- diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 45ecdac91..05b3044b6 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c @@ -787,7 +787,7 @@ do_resume (const char *args) case PS_ERROR: FPRINTF (stderr, "%s", - _("There is no call that could be suspended right now.\n")); + _("There is no call that could be resumed right now.\n")); return; case PS_LISTEN: /* expected state, do resume logic */ @@ -1054,6 +1054,8 @@ handle_command (void *cls, ptr = &message[strlen (commands[i].command)]; while (isspace ((int) *ptr)) ptr++; + if ('\0' == ptr) + ptr = NULL; commands[i].Action (ptr); } diff --git a/src/core/core_api.c b/src/core/core_api.c index 34c235bbd..f07d1ca47 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -1424,7 +1424,6 @@ core_mq_ntr (void *cls, size_t size, return 0; } memcpy (buf, mh, msg_size); - GNUNET_MQ_impl_send_commit (mq); GNUNET_MQ_impl_send_continue (mq); return msg_size; } @@ -1448,7 +1447,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq, GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "core-mq", "Sending queued message (size %u)\n", ntohs (msg->size)); mqs->th = GNUNET_CORE_notify_transmit_ready (mqs->core, GNUNET_YES, 0, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_TIME_UNIT_FOREVER_REL, &mqs->target, ntohs (msg->size), core_mq_ntr, mq); } @@ -1459,7 +1458,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq, * destruction of a message queue. * Implementations must not free @a mq, but should * take care of @a impl_state. - * + * * @param mq the message queue to destroy * @param impl_state state of the implementation */ @@ -1478,7 +1477,7 @@ core_mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state) /** * Implementation function that cancels the currently sent message. - * + * * @param mq message queue * @param impl_state state specific to the implementation */ diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 651c698e1..26330f3ee 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h @@ -389,9 +389,9 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, /** - * Replace the handlers of a message queue with new handlers. - * Takes effect immediately, even for messages that already have been received, but for - * with the handler has not been called. + * Replace the handlers of a message queue with new handlers. Takes + * effect immediately, even for messages that already have been + * received, but for with the handler has not been called. * * If the message queue does not support receiving messages, * this function has no effect. @@ -506,16 +506,6 @@ void * GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq); -/** - * Mark the current message as irrevocably sent, but do not - * proceed with sending the next message. - * Will call the appropriate GNUNET_MQ_NotifyCallback, if any. - * - * @param mq message queue - */ -void -GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq); - /** @} */ /* end of group mq */ #endif diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index b35a4dc14..9b18df8dd 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -1710,7 +1710,6 @@ mesh_mq_ntr (void *cls, size_t size, GNUNET_assert (msize <= size); memcpy (buf, msg, msize); GNUNET_MQ_impl_send_continue (mq); - GNUNET_MQ_impl_send_commit (mq); return msize; } diff --git a/src/util/mq.c b/src/util/mq.c index d8659ec40..3cf5da496 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -120,12 +120,6 @@ struct GNUNET_MQ_Handle */ struct GNUNET_MQ_Envelope *current_envelope; - /** - * Has the current envelope been commited? - * Either GNUNET_YES or GNUNET_NO. - */ - int commited; - /** * Map of associations, lazily allocated */ @@ -265,25 +259,27 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev) void GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) { + struct GNUNET_MQ_Envelope *current_envelope; + /* call is only valid if we're actually currently sending * a message */ - GNUNET_assert (NULL != mq); - GNUNET_assert (NULL != mq->current_envelope); - GNUNET_assert (GNUNET_YES == mq->commited); - mq->commited = GNUNET_NO; - GNUNET_free (mq->current_envelope); + current_envelope = mq->current_envelope; + GNUNET_assert (NULL != current_envelope); if (NULL == mq->envelope_head) { mq->current_envelope = NULL; - return; } - - GNUNET_assert (NULL != mq->envelope_tail); - GNUNET_assert (NULL != mq->envelope_head); - mq->current_envelope = mq->envelope_head; - GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, - mq->current_envelope); - mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); + else + { + mq->current_envelope = mq->envelope_head; + GNUNET_CONTAINER_DLL_remove (mq->envelope_head, + mq->envelope_tail, + mq->current_envelope); + mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); + } + if (NULL != current_envelope->sent_cb) + current_envelope->sent_cb (current_envelope->sent_cls); + GNUNET_free (current_envelope); } @@ -362,25 +358,6 @@ GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq) } - -/** - * Mark the current message as irrevocably sent, but do not - * proceed with sending the next message. - * Will call the appropriate GNUNET_MQ_NotifyCallback, if any. - * - * @param mq message queue - */ -void -GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq) -{ - GNUNET_assert (NULL != mq->current_envelope); - GNUNET_assert (GNUNET_NO == mq->commited); - mq->commited = GNUNET_YES; - if (NULL != mq->current_envelope->sent_cb) - mq->current_envelope->sent_cb (mq->current_envelope->sent_cls); -} - - struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type) { @@ -479,9 +456,6 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq, GNUNET_assert (NULL != mq); GNUNET_assert (NULL != state); - - GNUNET_MQ_impl_send_commit (mq); - state->th = GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), GNUNET_TIME_UNIT_FOREVER_REL, @@ -596,9 +570,6 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, GNUNET_assert (NULL != state); GNUNET_assert (NULL == state->th); - - GNUNET_MQ_impl_send_commit (mq); - state->th = GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO,