[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37385 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37385 - in gnunet/src: include util |
Date: |
Mon, 27 Jun 2016 14:20:12 +0200 |
Author: grothoff
Date: 2016-06-27 14:20:12 +0200 (Mon, 27 Jun 2016)
New Revision: 37385
Modified:
gnunet/src/include/gnunet_mq_lib.h
gnunet/src/util/mq.c
Log:
add function to obtain mq length
Modified: gnunet/src/include/gnunet_mq_lib.h
===================================================================
--- gnunet/src/include/gnunet_mq_lib.h 2016-06-27 09:51:31 UTC (rev 37384)
+++ gnunet/src/include/gnunet_mq_lib.h 2016-06-27 12:20:12 UTC (rev 37385)
@@ -433,6 +433,16 @@
/**
+ * Obtain the current length of the message queue.
+ *
+ * @param mq queue to inspect
+ * @return number of queued, non-transmitted messages
+ */
+unsigned int
+GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq);
+
+
+/**
* Send a message with the give message queue.
* May only be called once per message.
*
Modified: gnunet/src/util/mq.c
===================================================================
--- gnunet/src/util/mq.c 2016-06-27 09:51:31 UTC (rev 37384)
+++ gnunet/src/util/mq.c 2016-06-27 12:20:12 UTC (rev 37385)
@@ -140,6 +140,11 @@
* @e assoc_map
*/
uint32_t assoc_id;
+
+ /**
+ * Number of entries we have in the envelope-DLL.
+ */
+ unsigned int queue_length;
};
@@ -264,15 +269,23 @@
{
if (NULL == mq->error_handler)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "mq: got error %d, but no handler installed\n",
- (int) error);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Got error %d, but no handler installed\n",
+ (int) error);
return;
}
- mq->error_handler (mq->error_handler_cls, error);
+ mq->error_handler (mq->error_handler_cls,
+ error);
}
+/**
+ * Discard the message queue message, free all
+ * allocated resources. Must be called in the event
+ * that a message is created but should not actually be sent.
+ *
+ * @param mqm the message to discard
+ */
void
GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm)
{
@@ -282,6 +295,19 @@
/**
+ * Obtain the current length of the message queue.
+ *
+ * @param mq queue to inspect
+ * @return number of queued, non-transmitted messages
+ */
+unsigned int
+GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq)
+{
+ return mq->queue_length;
+}
+
+
+/**
* Send a message with the give message queue.
* May only be called once per message.
*
@@ -302,6 +328,7 @@
GNUNET_CONTAINER_DLL_insert_tail (mq->envelope_head,
mq->envelope_tail,
ev);
+ mq->queue_length++;
return;
}
mq->current_envelope = ev;
@@ -367,6 +394,7 @@
GNUNET_CONTAINER_DLL_remove (mq->envelope_head,
mq->envelope_tail,
mq->current_envelope);
+ mq->queue_length--;
mq->send_impl (mq,
mq->current_envelope->mh,
mq->impl_state);
@@ -876,8 +904,10 @@
GNUNET_CONTAINER_DLL_remove (mq->envelope_head,
mq->envelope_tail,
ev);
+ mq->queue_length--;
GNUNET_MQ_discard (ev);
}
+ GNUNET_assert (0 == mq->queue_length);
if (NULL != mq->current_envelope)
{
/* we can only discard envelopes that
@@ -956,6 +986,7 @@
GNUNET_CONTAINER_DLL_remove (mq->envelope_head,
mq->envelope_tail,
mq->current_envelope);
+ mq->queue_length--;
mq->send_impl (mq,
mq->current_envelope->mh,
mq->impl_state);
@@ -967,6 +998,7 @@
GNUNET_CONTAINER_DLL_remove (mq->envelope_head,
mq->envelope_tail,
ev);
+ mq->queue_length--;
}
ev->parent_queue = NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37385 - in gnunet/src: include util,
gnunet <=