aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-08 16:32:50 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-08 16:32:50 +0000
commit4ab9f527078552f8a26008f6856fec0b21607a54 (patch)
tree05c6ee49edbcbf01910f2bc1b7a33fa042a3f301
parentdedde9454bd4cb4ce90c5803fcf135968408aaac (diff)
downloadgnunet-4ab9f527078552f8a26008f6856fec0b21607a54.tar.gz
gnunet-4ab9f527078552f8a26008f6856fec0b21607a54.zip
add GNUNET_MQ_set_handlers_closure API
-rw-r--r--src/include/gnunet_mq_lib.h12
-rw-r--r--src/util/mq.c24
2 files changed, 34 insertions, 2 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 7da5aa778..43cefca9f 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -536,6 +536,18 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send,
536 536
537 537
538/** 538/**
539 * Change the closure argument in all of the `handlers` of the
540 * @a mq.
541 *
542 * @param mq to modify
543 * @param handlers_cls new closure to use
544 */
545void
546GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq,
547 void *handlers_cls);
548
549
550/**
539 * Call a callback once the envelope has been sent, that is, 551 * Call a callback once the envelope has been sent, that is,
540 * sending it can not be canceled anymore. 552 * sending it can not be canceled anymore.
541 * There can be only one notify sent callback per envelope. 553 * There can be only one notify sent callback per envelope.
diff --git a/src/util/mq.c b/src/util/mq.c
index 185fe5170..b9bc4f2f1 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -473,6 +473,26 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send,
473 473
474 474
475/** 475/**
476 * Change the closure argument in all of the `handlers` of the
477 * @a mq.
478 *
479 * @param mq to modify
480 * @param handlers_cls new closure to use
481 */
482void
483GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq,
484 void *handlers_cls)
485{
486 unsigned int i;
487
488 if (NULL == mq->handlers)
489 return;
490 for (i=0;NULL != mq->handlers[i].cb; i++)
491 mq->handlers[i].cls = handlers_cls;
492}
493
494
495/**
476 * Get the message that should currently be sent. 496 * Get the message that should currently be sent.
477 * Fails if there is no current message. 497 * Fails if there is no current message.
478 * Only useful for implementing message queues, 498 * Only useful for implementing message queues,
@@ -662,8 +682,8 @@ GNUNET_MQ_queue_for_server_client (struct GNUNET_SERVER_Client *client)
662 mq->impl_state = scss; 682 mq->impl_state = scss;
663 scss->client = client; 683 scss->client = client;
664 GNUNET_SERVER_client_keep (client); 684 GNUNET_SERVER_client_keep (client);
665 mq->send_impl = server_client_send_impl; 685 mq->send_impl = &server_client_send_impl;
666 mq->destroy_impl = server_client_destroy_impl; 686 mq->destroy_impl = &server_client_destroy_impl;
667 return mq; 687 return mq;
668} 688}
669 689