gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37374 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r37374 - in gnunet/src: include util
Date: Sat, 25 Jun 2016 19:39:44 +0200

Author: grothoff
Date: 2016-06-25 19:39:44 +0200 (Sat, 25 Jun 2016)
New Revision: 37374

Modified:
   gnunet/src/include/gnunet_mq_lib.h
   gnunet/src/util/mq.c
Log:
add GNUNET_MQ_send_copy

Modified: gnunet/src/include/gnunet_mq_lib.h
===================================================================
--- gnunet/src/include/gnunet_mq_lib.h  2016-06-25 17:32:18 UTC (rev 37373)
+++ gnunet/src/include/gnunet_mq_lib.h  2016-06-25 17:39:44 UTC (rev 37374)
@@ -445,6 +445,18 @@
 
 
 /**
+ * Send a copy of a message with the give message queue.
+ * Can be called repeatedly on the same envelope.
+ *
+ * @param mq message queue
+ * @param ev the envelope with the message to send.
+ */
+void
+GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq,
+                     const struct GNUNET_MQ_Envelope *ev);
+
+
+/**
  * Cancel sending the message. Message must have been sent with
  * #GNUNET_MQ_send before.  May not be called after the notify sent
  * callback has been called

Modified: gnunet/src/util/mq.c
===================================================================
--- gnunet/src/util/mq.c        2016-06-25 17:32:18 UTC (rev 37373)
+++ gnunet/src/util/mq.c        2016-06-25 17:39:44 UTC (rev 37374)
@@ -310,6 +310,35 @@
 
 
 /**
+ * Send a copy of a message with the give message queue.
+ * Can be called repeatedly on the same envelope.
+ *
+ * @param mq message queue
+ * @param ev the envelope with the message to send.
+ */
+void
+GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq,
+                     const struct GNUNET_MQ_Envelope *ev)
+{
+  struct GNUNET_MQ_Envelope *env;
+  uint16_t msize;
+
+  msize = ntohs (ev->mh->size);
+  env = GNUNET_malloc (sizeof (struct GNUNET_MQ_Envelope) +
+                       msize);
+  env->mh = (struct GNUNET_MessageHeader *) &env[1];
+  env->sent_cb = ev->sent_cb;
+  env->sent_cls = ev->sent_cls;
+  memcpy (&env[1],
+          ev->mh,
+          msize);
+  GNUNET_MQ_send (mq,
+                  env);
+}
+
+
+
+/**
  * Task run to call the send implementation for the next queued
  * message, if any.  Only useful for implementing message queues,
  * results in undefined behavior if not used carefully.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]