return 0;
}
memcpy (buf, mh, msg_size);
- GNUNET_MQ_impl_send_commit (mq);
GNUNET_MQ_impl_send_continue (mq);
return msg_size;
}
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);
}
* 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
*/
/**
* Implementation function that cancels the currently sent message.
- *
+ *
* @param mq message queue
* @param impl_state state specific to the implementation
*/
/**
- * 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.
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
*/
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
*/
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);
}
}
-
-/**
- * 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)
{
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,
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,