diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-25 17:39:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-25 17:39:44 +0000 |
commit | 2fa661c71bbfe37518bdefd7561aca475278b86a (patch) | |
tree | 86dda6c5f588441e45671616339b17532d83a013 /src/util/mq.c | |
parent | 41f06b9223347f779237d0d56ef8fe9e2d813789 (diff) | |
download | gnunet-2fa661c71bbfe37518bdefd7561aca475278b86a.tar.gz gnunet-2fa661c71bbfe37518bdefd7561aca475278b86a.zip |
add GNUNET_MQ_send_copy
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index fb679c18d..b84db002a 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -310,6 +310,35 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | |||
310 | 310 | ||
311 | 311 | ||
312 | /** | 312 | /** |
313 | * Send a copy of a message with the give message queue. | ||
314 | * Can be called repeatedly on the same envelope. | ||
315 | * | ||
316 | * @param mq message queue | ||
317 | * @param ev the envelope with the message to send. | ||
318 | */ | ||
319 | void | ||
320 | GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq, | ||
321 | const struct GNUNET_MQ_Envelope *ev) | ||
322 | { | ||
323 | struct GNUNET_MQ_Envelope *env; | ||
324 | uint16_t msize; | ||
325 | |||
326 | msize = ntohs (ev->mh->size); | ||
327 | env = GNUNET_malloc (sizeof (struct GNUNET_MQ_Envelope) + | ||
328 | msize); | ||
329 | env->mh = (struct GNUNET_MessageHeader *) &env[1]; | ||
330 | env->sent_cb = ev->sent_cb; | ||
331 | env->sent_cls = ev->sent_cls; | ||
332 | memcpy (&env[1], | ||
333 | ev->mh, | ||
334 | msize); | ||
335 | GNUNET_MQ_send (mq, | ||
336 | env); | ||
337 | } | ||
338 | |||
339 | |||
340 | |||
341 | /** | ||
313 | * Task run to call the send implementation for the next queued | 342 | * Task run to call the send implementation for the next queued |
314 | * message, if any. Only useful for implementing message queues, | 343 | * message, if any. Only useful for implementing message queues, |
315 | * results in undefined behavior if not used carefully. | 344 | * results in undefined behavior if not used carefully. |